A promise is an object that produces a value in the future upon the completion of (more often than not) an api call, or some other supplied argument. At any given time, a promise is either either completed, rejected, or pending. Through callbacks we can utilize the completed value or provide feedback for what it may not have been provided.
For instance, in my most recent project, JetLog, I utilized promises extensively in handling and dealing with JSON data from my companion Rails API. As seen below, in my Redux Logs module, I make an asynchronous call to my API to fetch “logs”. Using .then(), I’m able to promise the function that something will be done with the data retrieved.
<a href="https://medium.com/media/8eedb6c2e3a6c879f1eab7e2d3bf6041/href">https://medium.com/media/8eedb6c2e3a6c879f1eab7e2d3bf6041/href</a>
In this case, I’m…
<a href="https://medium.com/media/d06428df74f3bda61e92edaa67364a12/href">https://medium.com/media/d06428df74f3bda61e92edaa67364a12/href</a>