You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throw new MongooseError('Model.prototype.save() no longer accepts a callback'); ....... Fixing use then and catch instead of use if and else method
#32
Open
UmitRock opened this issue
May 14, 2023
· 0 comments
The text was updated successfully, but these errors were encountered:
UmitRock
changed the title
throw new MongooseError('Model.prototype.save() no longer accepts a callback'); Fixing use then and catch
throw new MongooseError('Model.prototype.save() no longer accepts a callback'); ....... Fixing use then and catch instead of use if and else method
May 14, 2023
use new code of register post
app.post("/register", function(req, res) {
const newUser = new User({
email: req.body.username,
password: req.body.password
});
newUser.save().then(function(){
res.render("secrets");
}).catch(function (err){
console.log(err);
});
});
instead of old code of register post
app.post("/register", function(req, res){
const newUser = new User({
email: req.body.username,
password: req.body.password
});
newUser.save(function(err){
if (err) {
console.log(err);
} else {
res.render("secrets");
}
});
});
The text was updated successfully, but these errors were encountered: