How to escape async/await hell

Click for: original source

Javascript developer Aditya Agarwal published this interesting article about perils of asynchronous Javascript. While working with Asynchronous JavaScript, people often write multiple statements one after the other and slap an await before a function call.

This causes performance issues, as many times one statement doesn’t depend on the previous one – but you still have to wait for the previous one to complete.

async/await freed us from callback hell, but people have started abusing it – leading to the birth of async/await hell

The article then gives you:

  • Few examples of async await hell
  • Detailed explanation what is wrong in the example
  • Advice on how to get out of async / await hell
  • Example code with fixes

One interesting property of promises is that you can get a promise in one line and wait for it to resolve in another. Sweet and to the point article, with great code examples!

[Read More]

Tags javascript programming nodejs