Gabriele Ferro Home


Not these.

One of the requirements of the fifth OpenClassRooms project is the use of the Promises.

I had heard about it first with the OpenClassRooms course (they devote very few lines to the topic) and then I deepened the topic with freeCodeCamp.

So far I preferred the good old XMLHttpRequest() that I know well, so I can do the conversion later, using the Promises and the fetch() api.

Day 52: 28 September 2020

**Today’s Progress:**

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.

**Link to tweet:**

July 2024


Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.