Skip to content

Instantly share code, notes, and snippets.

@FrankV01
Forked from zspecza/callback-hell.js
Last active July 3, 2017 03:48
Show Gist options
  • Save FrankV01/42007f71c0e9fd3b3b89fca3b5c11aa0 to your computer and use it in GitHub Desktop.
Save FrankV01/42007f71c0e9fd3b3b89fca3b5c11aa0 to your computer and use it in GitHub Desktop.
findSomething(function(error, something) { //callback 1
if (error) {
throw new Error(error)
}
transformSomething(something, function(error, transformed) { //callback 2
if (error) {
throw new Error(error)
}
validateTransformed(transformed, function(error, validated) { //callback 3
if (error) {
throw new Error(error)
}
console.log('data is valid:', validated)
}) //end 3
}) //end 2
}) //end 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment