#Anandu

1 messages · Page 1 of 1 (latest)

willow brook
faint hingeBOT
#

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:

willow brook
#

You need to export const GET = handlers

faint hingeBOT
#

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?

willow brook
#

export all http verb .. POST, GET, PUT, etc…

plain ridge
#

Hey..thanks

plain ridge
#

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

willow brook
#

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

plain ridge
#

Oh okay...thankss

#

I just went on and did it on next 12 🥲....

plain ridge
#

Hey