Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
User promise
exports.createOrAddUserPromise = (req, res, next) => {
User.findUserPromise(req.body)
.then(user => {
if (user) {
const existingUser = new User(user);
return newUser.updatePromise(req.body)
}
const newUser = new User();
return newUser.savePromise(req.body);
})
.then(data => res.send(data))
.catch(e => next(e));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.