Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Async await
exports.createOrAddUserAsync = async (req, res, next) => {
try {
const user = await User.findUserPromise(req.body);
if (user) {
const existingUser = new User(user);
const data = await existingUser.updatePromise(req.body);
return res.send(data);
const newUser = new User();
const data = await newUser.savePromise(req.body);
return res.send(data);
} catch (e) {
return next(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment