skip to Main Content

Mongodb – NodeJS (express) – Javascript promise is being executed whether success or failure, How can I make a promise for each case?

exports.postDeleteProduct = (req, res, next) => { const userId = req.body.userId; User.deleteOne({ _id: userId, userId: req.session.userAuth._id }) .then(() => { console.log("DESTROYED PRODUCT"); //process reaching here whether the above deleteOne happens or not res.redirect("/users"); }) .catch((err) => console.log(err)); }; Also, the…

VIEW QUESTION

MONGODB findOne() needs a variable

My function is set to find email brought from /login POST method, but I am failing to declare the variable properly, what is the variable to be inserted into the findOne form on app.get('/data')? I have: app.post('/login', function (req, res)…

VIEW QUESTION
Back To Top
Search