The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise. Promise object that is resolved with the given value.
If the value is a promise , that promise is . It behaves the same as calling Promise. At this point you fall into one of these .
Get to know JavaScript Promises better. Promises help you naturally handle errors, and write cleaner code by not having. Once all of the APIs return promises , it should be relatively rare that you need.
MDN - The mozilla developer network has great documentation on promises. As a rule of thumb for JavaScript I always read documentation from MDN Web Docs. Of all the resources I think they . Promises are becoming a big part of the JavaScript worl with many new APIs being implemented with the promise.
The XMLHttpRequest API is async but does not use the Promises API.
See examples on MDN here: . The other provide good explanations, but it might be easier to express this using the concept of skipping over. I have read about promises a lot.