Sitemap
Better Programming

Advice for programmers.

Member-only story

JavaScript: Promises or async-await

4 min readAug 21, 2018

--

I recently read a medium post where the author claimed that using async-await is better than using promises.

While this might be true in general cases, I think that generalisation is too broad and doesn’t do justice to either async-await or promises.

For someone new to JavaScript, making sense of these and deciding which one to use can be a challenge. In this post, I will list things that I have learned about these and how I decide when to use which.

I read somewhere that async-await is syntactical sugar for using promises. So, before getting to know async-await or deciding which approach to use, make sure that you have a good understanding of promises and async-await.

Here are some thumb rules that I follow.

Thumb Rules for Using Promises

  1. Use promises whenever you are using asynchronous or blocking code.
  2. resolve maps to then and reject maps to catch for all practical purposes.
  3. Make sure to write both .catch and .then methods for all…

--

--

Responses (28)