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…