The most powerful feature of the promise lies in its ability to chain calls, thereby making code look synchronous. A chain looks like this:
getData() .then(getMoreData) .then(getEvenMoreData) .catch(handleError)
This makes the code very easy to read. You are able to tell in which order things happen; namely, getData() followed by getMoreData(), followed by getEvenMoreData(). Not only are we able to run the methods in the order that we want, but we are also able to access the data from the previous promise, like so:
function getData() { return new Promise((resolve, reject) => { setTimeout(() => { resolve('data'); }) })}function getMoreData(data) { // data is from getData return new Promise((resolve, ...