Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@UmitRock
Copy link

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

@UmitRock 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant