Skip to content

Instantly share code, notes, and snippets.

@velotio-tech
Last active May 30, 2017 04:12
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 velotio-tech/a4f579d0c43f33524feb712c033dfdea to your computer and use it in GitHub Desktop.
Save velotio-tech/a4f579d0c43f33524feb712c033dfdea 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