Skip to content

Instantly share code, notes, and snippets.

@alexandremaeda
Created October 28, 2016 16:37
Show Gist options
  • Save alexandremaeda/0125c96b2a1e74efd9434bdd0a4a2ce0 to your computer and use it in GitHub Desktop.
Save alexandremaeda/0125c96b2a1e74efd9434bdd0a4a2ce0 to your computer and use it in GitHub Desktop.
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