#Anandu
1 messages · Page 1 of 1 (latest)
Hi @willow brook. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
You need to export const GET = handlers
Sorry @willow brook, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
export all http verb .. POST, GET, PUT, etc…
Hey..thanks
const { NextResponse, NextRequest } = require("next/server") ; export async function GET(){ let products= await Product.find() return NextRequest.json({products}),NextResponse.json({products})}
and this is the middleware
export async function connectDb(NextRequest){ if (mongoose.connections[0].readyState){ return NextResquest.json({NextResquest}) }}
is this the right way to do it? im new to this..thanks
The GET looks right. Not sure about middleware. It’s typically used for very light operations such as query string rewrite, auth check, etc… not quite sure what you’re trying to do in that middleware
Hey