-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
This does not work as documented (in Typescript)
const handler = (): Response => {
console.log("Hello world!");
const data = { hello: "world" };
return Response.json({ data });
};
const api = Api();
api.post(handler);
export async function POST(request: NextRequest, ctx: ApiRequestContext) {
return api.run(request, ctx);
}
When I run production npm run build
I get:
Type error: Route "src/app/api/waitlist/route.ts" has an invalid export:
"Promise<unknown>" is not a valid POST return type:
Expected "void | Response | Promise<void | Response>", got "Promise<unknown>".
Expected "Promise<void | Response>", got "Promise<unknown>".
Expected "void | Response", got "unknown".
to fix you'll have to as Promise<any>
export async function POST(request: NextRequest, ctx: ApiRequestContext) {
return api.run(request, ctx) as Promise<any>;
}
▲ Next.js 14.0.4
OgDev-01, aalhadhoud and mastdiekin
Metadata
Metadata
Assignees
Labels
No labels