I have a get endpoint as follows:
import { NextResponse } from 'next/server';
import connection from '@config/db';
export async function GET(req: Request, context: { params: { providerId: number } }) {
const providerId = await context.params.providerId;
// Placeholder for current user ID (replace this with actual user ID from session/auth)
const currentUserId = 2; // Change to dynamically fetch from your auth system
...
It works but I get this error:
Error: Route "/api/appProviders/listProvider/[providerId]" used params.providerId
. params
should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
Any idea on how i could get rid of it? Thank you
I tried various ways but can't seem to find the solution
Just follow the solution provided by Next https://nextjs.org/docs/messages/sync-dynamic-apis
I have installed the npx package and no more problems.
I had posted this solution a while ago but it was delete by a moderator, not sure why?