One of the requirements of the fifth OpenClassRooms project is the use of the Promises.
Day 52: 28 September 2020
I have postponed the use of the Promises until today.
The promises allow us to avoid the so-called "callback hell". That is, the presence in the code of subsequent nested functions.
…And also using the Promises we will make the code more readable. Also if we use the API fetch we will be obliged to use the Promises.
With Git I've created a branch dedicated to converting my code, so I don't risk making the site non-functional or worse, breaking it and not being able to return to a working state.
Once I've done this, I've thoroughly studied the documentation to understand the differences between XMLHttpRequest() and Fetch API
.then( I coded a working solution );
With a lot of sincerity I confess that I don't find it "simple" at all to write a Promise using ES6 and arrow functions.
But in the end what counts in these cases is the result. It works!
During my research I came across this very interesting article that explains how to use a REST API via curl.