londonappbrewery / Authentication-Secrets

Companion Code for the Authentication Module on The Complete 2019 Web Development Bootcamp
https://www.appbrewery.co
440 stars 524 forks source link

MongooseError: Model.prototype.save() no longer accepts a callback in lesson 378 resolved #30

Open bommmi999 opened 1 year ago

bommmi999 commented 1 year ago

if anyone face the above situation use promise instead of a callback function for example : // User.findOne({ email: username }, function (err, foundUser) { // if (err) { // console.log(err); // } else { // if (foundUser.password === password) { // res.render("secrets"); // } // } // }); the above code can be rewritten using promises below User.findOne({ email: username }) .then((foundUser) => { if (foundUser.password === password) { res.render("secrets"); } })