Skip to content

Instantly share code, notes, and snippets.

@Technoash
Created March 1, 2016 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Technoash/688650842e4a40941e46 to your computer and use it in GitHub Desktop.
Save Technoash/688650842e4a40941e46 to your computer and use it in GitHub Desktop.
validateRegister(req.body)
.then(function(errors){
if(errors.count > 0){
res.send({state: 'failure', registerFormErrors: errors.messages, errorCount: errors.count});
return;
}
db.createUser(req.body.name, req.body.email, req.body.password)
.then(function(newUser){
console.log(2);
res.send({state: 'success', name: newUser.name});
})
.catch(function(err){
//catch 1
throw err;
});
})
.catch(function(err){
//catch 2
console.log(err);
res.status(500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment