How to write beautiful Node.js APIs using async/await and the Firebase Database
Paul Breslin
5508

Hey,

Getting to the middle of the article, I was thinking — “this guy lectures me about async/await and how good it is over promises with the ‘pyramid of doom’ example when he doesn’t even know how to write code with promises”.

But, after reading further, I saw that you do know how to work with promises, you just picked a bad example of promises when comparing to async/await code.

This how the “pyramid of doom” you’ve mentioned should have looked like.
The code doesn’t look way worse than the async/await version of it, yet its fashion is still asynchronous — unlike the async/await version which provides the elegancy of synchronous code.

example.firstAsyncRequest()
.then(example.secondAsyncRequest)
.then(example.thirdAsyncRequest)
.catch(err => // catch all);
Show your support

Clapping shows how much you appreciated Jonathan Yaniv’s story.