Created
June 6, 2017 21:14
-
-
Save chrisdel101/4b7cce928eaa42f1350f26a9a677a4cc 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
router.post("/", (req,res) => { | |
req.checkBody('name', 'Cannot be empty').notEmpty() | |
var entry = { | |
name:req.body.username, | |
email: req.body.email | |
} | |
Email.find({"email":entry.email}, (err, email) => { | |
console.log(email) | |
if(err){ | |
console.log(err) | |
} | |
if(email.length){ | |
console.log('exists') | |
// res.send('email already exists') | |
alert('email aleardy exists') | |
return res.redirect('/') | |
} else { | |
console.log("doesn't exist") | |
var entered = new Email(entry) | |
entered.save() | |
console.log('email saved') | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment