Created
October 28, 2016 16:37
-
-
Save alexandremaeda/0125c96b2a1e74efd9434bdd0a4a2ce0 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
const leadRepo = require('../lead/repository'); | |
let dto = { | |
email: req.body.email | |
}; | |
leadRepo.findByEmail(dto.email).then( (doc) => { | |
if(doc){ | |
res.status(200).end(); | |
} | |
else{ | |
return leadRepo.add(dto); | |
} | |
}) | |
.then( lead => { | |
res.status(201).json(lead); | |
}) | |
.catch( (err) => { | |
console.log(err); | |
res.status(500).end(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment