DEV Community

Discussion on: 6 points you need to know about async/await in JavaScript

Collapse
danielsan profile image
Daniel Santana

Iโ€™m not sure why the first block of code in the article uses promises like the old callback hell, but here it is the proper way to write that first block of code:

fetchPizzas()
  .then( sortByToppings )
  .then( checkDeliveryOptions )
  .then( checkBirthdayGift )
  .then( sendToCustomer ); 

And, in my opinion, it looks better then the alternatives offered by the article, not mentioning the testability of it.

Collapse
avalander profile image
Avalander

Agree, I think promises are better that async/await when it comes to function composition.

Collapse
yashints profile image
Yaser Adel Mehraban Author

That was a bad example, not to be used