Promises are objects that represent the eventual outcome of an asynchronous operation. A
Promise object can be in one of three states:
Errorof some kind.
We refer to a promise as settled if it is no longer pending— it is either fulfilled or rejected. Let’s think of a dishwasher as having the states of a promise:
If our dishwashing promise is fulfilled, we’ll be able to perform related tasks, such as unloading the clean dishes from the dishwasher. If it’s rejected, we can take alternate steps, such as running it again with soap or washing the dishes by hand.
All promises eventually settle, enabling us to write logic for what to do if the promise fulfills or if it rejects.
Observe the diagram on the right. Here, we illustrate the different possible states of a dishwashing promise.