Skip to content

Instantly share code, notes, and snippets.

@darrell-parkhouse5151
Created February 20, 2018 03:53
Show Gist options
  • Select an option

  • Save darrell-parkhouse5151/c0d8b502aa54c5090df47aaf8b3c7c2f to your computer and use it in GitHub Desktop.

Select an option

Save darrell-parkhouse5151/c0d8b502aa54c5090df47aaf8b3c7c2f to your computer and use it in GitHub Desktop.
router.post('/users/register', function(req, res) {
var username = req.body.username;
var password = req.body.password;
User.findOne({username: username}, function() {
if (err) console.log(err);
if (user) {
res.json('userExists');
} else {
var user = new User({
username: username,
passwrod: password
});
user.save(function(err) {
if (err) {
console.log(err);
} else {
res.json("userRegistered");
}
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment