Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Created June 26, 2018 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitish24p/560db21ed1759cd19fb346decb77f592 to your computer and use it in GitHub Desktop.
Save nitish24p/560db21ed1759cd19fb346decb77f592 to your computer and use it in GitHub Desktop.
User callback
exports.createOrAddUser = (req, res, next) => {
User.findUser(req.body, (err, data) => {
if (err) {
return next(err)
};
if (data) {
const existingUser = new User(data);
existingUser.update(req.body, (err, data) => {
if (err) {
return next(err);
}
return res.send(data);
});
}
const newUser = new User();
newUser.addUser(req.body, (err, data) => {
if (err) {
return next(err);
}
return res.send(data);
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment