Async/Await: a Game Changer for Haters of Promise Chaining
...If you became a frontend engineer after 2015, chances are that you have used or at least heard about
Promise. As I have covered in my previous blog,Promisecan help us specify sequential relations between operations in asynchronous programming in a readable and maintainable manner.Promiseobject in JavaScript has methods, such asthenandcatch, that can help us organize the sequential execution of operations in a pattern called Promise Chaining. Clean and organized as Promise Chaining is, some people—especially those more accustomed to synchronous programming—find it unintuitive and confusing. Lucky for them, ECMAScript 2017 introduced a new feature that allows us to write asynchronous code as if it were synchronous. This new feature consists of two keywords:asyncandawait. In this article, I will cover the fundamentals ofasync/awaitand how to transition from Promise Chaining to usingasync/await.