You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// /src/controllers/UserController.tsimport{get,post,prefix}from'next-smoothie';
@prefix('users')exportdefaultclassUserController{
@get()// Handles GET requests to '/api/users'staticgetAllUsers(){return{hello: 'world'};}
@post('hello/:id/world')// Handles POST requests to '/api/users/hello/:id/world'staticpostHelloWorld(req: NextRequest,{ id }: {id: string}){constq=req.nextUrl.searchParams.get('q');constbody=awaitreq.json();return{ id, q, body };}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
NextJS API Routes look much better now.
See next-smoothie. I hope you'll find it useful!
Beta Was this translation helpful? Give feedback.
All reactions