Created
March 1, 2016 19:26
-
-
Save Technoash/685dde7298b0bbfe7328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validateRegister(req.body) | |
| .then(function(errors){ | |
| if(errors.count > 0){ | |
| res.send({state: 'failure', registerFormErrors: errors.messages, errorCount: errors.count}); | |
| return; | |
| } | |
| //this won't always happen | |
| return db.createUser(req.body.name, req.body.email, req.body.password); | |
| }) | |
| .then(function(newUser){ | |
| //what if createUser wasn't added to the chain? | |
| res.send({state: 'success', name: newUser.name}); | |
| }) | |
| .catch(function(err){ | |
| res.send(500); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment