Skip to content

Instantly share code, notes, and snippets.

@warrenca
Created March 3, 2017 10:33
Show Gist options
  • Save warrenca/732f5dc4255e14978e5eabe30187616a to your computer and use it in GitHub Desktop.
Save warrenca/732f5dc4255e14978e5eabe30187616a to your computer and use it in GitHub Desktop.
Callback hell
function process(callback) {
var name = "john";
if (name==="john") {
callback(null, "My name is john");
} else {
callback("I am not john");
}
}
process(function(error, message) {
if (error) {
console.error(error);
} else {
console.log(message);
}
})
@warrenca
Copy link
Author

warrenca commented Mar 3, 2017

Check out the corresponding Async-Await example -
https://gist.github.com/warrenca/9f11ceef456a3603d42d4c23b359e409 or in babel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment