• 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, Promise can help us specify sequential relations between operations in asynchronous programming in a readable and maintainable manner. Promise object in JavaScript has methods, such as then and catch, 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: async and await. In this article, I will cover the fundamentals of async/await and how to transition from Promise Chaining to using async/await.

    ...