Next.js Discord

Discord Forum

How to get search params inside API app directory

Answered
Vojin posted this in #help-forum
Open in Discord
In a page file I'm be able to something like this:

function Home({ params }: { params: { id: string } }) {
  console.log(params.id);
}

But inside api I can't get any data from request outside of query params. If I get the whole path, I can manually extract the params, but am wondering is there any smarter why?

3 Replies

Answer
Thanks a lot! I couldn’t find it