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");
}
})
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"); } })