how do you get the query string in next app dir api routes?

like on GET example.com/api/foo?bar=%22baz%22 i want to get { bar: "baz" }
4 Replies
mattddean
mattddean2y ago
Maybe try const params = new URLSearchParams(request.url.search); Not sure if that behaves differently depending on the runtime
cornflour
cornflour2y ago
wait im dumb sorry
cornflour
cornflour2y ago
in this example they seem to also show the query string for route handler https://beta.nextjs.org/docs/routing/route-handlers#dynamic-route-handlers
Routing: Route Handlers | Next.js
Route Handlers are a new way to create custom request handlers for a given route. All HTTP methods are supported, including GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS.
Want results from more Discord servers?
Add your server