Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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