How to get query params in nextjs api route? #68218
-
I have an api endpoint export async function DELETE(request: NextApiRequest) {
// how to access fileKey query param?
} I feel like nextjs documentation is confused between query params and path params. In the link below, they give an example of whats referred to path param(at least in Spring/java world). Its not a query param i.e., that starts with a question mark. So how do I get access to query params(the real query params ?fileKey not path param /fileKey)? Note that this is in an api route meaning it will run on the server so I wont have access to useSearchParams hook which apparently is a client side hook according to docs anyway https://nextjs.org/docs/pages/building-your-application/routing/api-routes#dynamic-api-routes |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Never mind, I found it here in some other link by accident: https://nextjs.org/docs/app/building-your-application/routing/route-handlers#opting-out-of-caching I recommend adding this example to api route page in the docs and also updating that text which I mentioned where they say they are talking about query params but give an example of path param. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Never mind, I found it here in some other link by accident: https://nextjs.org/docs/app/building-your-application/routing/route-handlers#opting-out-of-caching
I recommend adding this example to api route page in the docs and also updating that text which I mentioned where they say they are talking about query params but give an example of path param.