'ParamCheck<RouteContext>
Answered
Japanese anchovy posted this in #help-forum
Japanese anchovyOP
I'm trying to run npm build and I keep getting this type error
Type error: Type '{ tag: "GET"; param_position: "second"; param_type: RouteParams; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
The types of 'param_type.params' are incompatible between these types.
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
code below ---
type RouteParams = { params: { id: string } };
export async function GET(_request: NextRequest, { params }: RouteParams) {
const notebook = await prisma.notebook.findUnique({
where: { id: params.id },
});
I keep getting the same error no matter how I wrote my code.
Type error: Type '{ tag: "GET"; param_position: "second"; param_type: RouteParams; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
The types of 'param_type.params' are incompatible between these types.
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
code below ---
type RouteParams = { params: { id: string } };
export async function GET(_request: NextRequest, { params }: RouteParams) {
const notebook = await prisma.notebook.findUnique({
where: { id: params.id },
});
I keep getting the same error no matter how I wrote my code.
Answered by B33fb0n3
can you name the request
After that it should look like this:
Ignore the promise params when you are not using next15
request
and inline the types?After that it should look like this:
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ slug: string }> }
) {
const slug = ...
}
Ignore the promise params when you are not using next15
3 Replies
can you name the request
After that it should look like this:
Ignore the promise params when you are not using next15
request
and inline the types?After that it should look like this:
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ slug: string }> }
) {
const slug = ...
}
Ignore the promise params when you are not using next15
Answer
Japanese anchovyOP
Thank you. Problem solve.
happy to help