Understanding JavaScript Promises Part Three: Await and Async

That Jeff Guy
4 min readOct 15, 2019
Image Courtesy of Max Pixel

Promises Can Get Messy

In the previous article, I talked about chaining promises together to build flows. I talked about how catch was really syntactic sugar and that there were multiple ways to write equivalent flows. Now I’m going to talk about what to do when your promise chains start getting complicated.

Promises are often used when a user clicks a button or some other event happens that causes some work to begin. The logic execution is essentially happening in the background, and after a while, the UI is updated to let the user know that some action has taken place. When this logic is short and simple, it generally is pretty easy to manage. If the logic involves a lot of steps and calls a lot of external services to do the action, the promise chains can become messy and harder to update without breaking the code:

This isn’t too bad, but imagine if there was branching logic, such as skipping some of the steps. It isn’t entirely obvious how you would do that with the promise chains without nesting promises and…

--

--

That Jeff Guy

I'm a technology enthusiast, always searching for better ways of doing things. Lately that has been all things React/Angular. I also write a lot on Medium. :)