21
kurtr
8y

Just found this comment in some code I wrote a few months ago... don't think I've ever been more honest!

Comments
  • 1
    Isn't .catch() for errors, not .then()?
  • 0
    thought the first parameter of then is for success and the second for error callbacks, or .catch()
  • 1
    @internerd no clue truthfully. It's calling some third party library and this was probably re-typed from some example in the code. Since I have never caught an error I have no idea if it works!
  • 1
    *an error

    Now you're good! Ship it!
  • 1
    @kurtr chaining then() requires the previous then() to return a promise. In this case all then()'s will be called, you should be using catch().
    Alternatively you can include two params in the first then() for resolve() and reject().
Add Comment