Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created July 1, 2020 11:02
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 velotiotech/5f06d624f5a884558fcaa1c54c98c423 to your computer and use it in GitHub Desktop.
Save velotiotech/5f06d624f5a884558fcaa1c54c98c423 to your computer and use it in GitHub Desktop.
Node.js Async Hell
foo(arg, (err, val) => {
if (err) {
console.log(err);
} else {
val += 1;
bar(val, (err1, val1) => {
if (err) {
console.log(err1);
} else {
val1 += 2;
baz(val1, (err2, result) => {
if (err2) {
console.log(err2);
} else {
result += 3;
console.log(result); // 6
}
});
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment