Skip to content

Instantly share code, notes, and snippets.

@ruggeri
Created January 17, 2018 19:04
Show Gist options
  • Save ruggeri/113680e92b34490e23ccc236c835af7c to your computer and use it in GitHub Desktop.
Save ruggeri/113680e92b34490e23ccc236c835af7c to your computer and use it in GitHub Desktop.
two-argument then
promise.then((result) => {
// promise resolved successfully.
console.log(`Result is ${result}`);
}, (error) => {
// promise was failed
console.log(`Error is ${error}`);
});
// Also: promise.then(null, (error) => { ... }) is the same as promise.catch((error) => { ... }).
// The Promise#catch method is just a convenience. You can always just pass a null success handler to then.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment