Error: Property 'nextUrl' does not exist on type 'Request'
Answered
Waterman posted this in #help-forum
WatermanOP
I have a funciton,writen below, and I use that funciton to fetch data from two different client components, is my setup or correct or should I make another route.ts file somewhere to not have two get request in the same GET function?
But my real question, why do I get an error when using nextUrl?
Error: linked as picture
I appreciate all help, thanks 🙂
But my real question, why do I get an error when using nextUrl?
Error: linked as picture
I appreciate all help, thanks 🙂
export const GET = async (req: Request, res: Response) => {
const { method } = req;
const queryId = req.nextUrl.searchParams.get("id");
await mongooseConnect();
if (method === "GET") {
if (queryId) {
return NextResponse.json(await BasProdukt.findOne({ _id: queryId }));
}
}
if (method === "GET") {
return NextResponse.json(await BasProdukt.find());
}
};