January 2018
Beginner
658 pages
13h 10m
English
Now in order to actually do something when the promise gets either resolved or rejected, we need to call a promise method called then; somePromise.then. The then method lets us provide callback functions for both success and error cases. This is one of the areas where callbacks differ from promises. In a callback, we had one function that fired no matter what, and the arguments let us know whether or not things went well. With promises we'll have two functions, and this will be what determines whether or not things went as planned.
Now before we dive into adding two functions, let's start with just one. Right here, I'll call then, passing in one function. This function will only get called if the promise gets ...
Read now
Unlock full access