Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Created November 3, 2017 06:22
Show Gist options
  • Save saiumesh535/91894a2be7163fe3b25f14cfacb7c57c to your computer and use it in GitHub Desktop.
Save saiumesh535/91894a2be7163fe3b25f14cfacb7c57c to your computer and use it in GitHub Desktop.
mediumpost
async function check(req, res) {
someOtherFunction().then((a) => {
somethingElseFunction().then((b) => {
res.status(200).json({a: a, b: b});
}).catch((error) => {
res.send("error");
})
}).catch((error) => {
res.send("error");
})
}
someOtherFunction = () => {
return new Promise((resolve, reject) => {
setTimeout(function () {
resolve("something")
}, 10);
})
}
somethingElseFunction = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("not a error");
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment