Skip to content

throw new MongooseError('Model.prototype.save() no longer accepts a callback'); ....... Fixing use then and catch instead of use if and else method #32

@UmitRock

Description

@UmitRock

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions