I am trying to update a post. this is the file structure: /api/posts/[postId]/route.ts
. how can i get the postId
in PATCH
function in route.ts
file?
// PATCH api/posts/3
export const PATCH = async (req: NextRequest, res: NextResponse) => {
// get the `postId` somehow
}
i tried req.nextUrl.searchParams()
. but it only select query params.
2
Answers
in the router: