Skip to content

Instantly share code, notes, and snippets.

@aherve
Last active December 7, 2016 10:55
Show Gist options
  • Select an option

  • Save aherve/013a495705b89f192a81741f4aa71ca9 to your computer and use it in GitHub Desktop.

Select an option

Save aherve/013a495705b89f192a81741f4aa71ca9 to your computer and use it in GitHub Desktop.
function demoPromise (userId) {
User
.findById(userId)
.then(doSomethingAsync) // doSomething will receive `user` as argument if everything goes smoothly
.catch(dealWithIt) // here we catch both the `findById` and `doSomethingAsync` errors at once
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment