Created
June 26, 2018 17:14
-
-
Save nitish24p/560db21ed1759cd19fb346decb77f592 to your computer and use it in GitHub Desktop.
User callback
This file contains 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
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