skip to Main Content

Mongodb – connect mongoose in nextjs middleware

I'm trying to connect next.js app to mongodb via mongoose in _middeware file(./pages/_middleware.ts ) But I get this error on incoming requests: error - (middleware)node_modulesmongoosedistbrowser.umd.js (1242:0) @ ReferenceError: regeneratorRuntime is not defined How can I fix it?

VIEW QUESTION

Mongodb – how to send data to mongo via URL?

i post data to mongodb as following: app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended:true})); app.use('/insert',async(req,res)=>{ const newProduct=new product({ _id:req.body._id, name:req.body.name, description:req.body.description }); try{ await newProduct.save(); // res.json(newProduct); res.send(`${newProduct} inserted.`); //res.redirect('/'); } catch(err){ res.send(err); } }); Data is taken from the user. The user sends the…

VIEW QUESTION
Back To Top
Search