Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.