Next.js Discord

Discord Forum

E-commerce website App router

Unanswered
niikkhilsharma posted this in #help-forum
Open in Discord
import { createEdgeRouter } from 'next-connect';
import dbConnect from '@/backend/config/dbConnect';
import { newProduct } from '@/backend/controllers/productControllers';

const router = createEdgeRouter();
console.log('hii');
dbConnect();

router.post(newProduct);

export async function POST(req, res) {
    console.log('api');
    return router.run(req);
}

in this code the
console.log('hi')
is not in the context of the post() method so how making a post request prints hii
this code is from the app/api folder

0 Replies