Member-only story
JavaScript: Promises or async-await
A set of rules for when to use which
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
- Use promises whenever you are using asynchronous or blocking code.
resolvemaps tothenandrejectmaps tocatchfor all practical purposes.- Make sure to write both
.catchand.thenmethods for all the promises. - If something needs to be done in both cases use
.finally. - We only get one shot at mutating each promise.
- We can add multiple handlers to a single promise.
- The return type of all the methods in the
Promiseobject, regardless of whether they are static methods or prototype methods, is again aPromise. - In
Promise.all, the order of the promises are maintained in the values variable, irrespective of which promise was first resolved.
Once you have wrapped your head around promises, check out async-await. It helps you to write code that is much more readable. When it is not used properly, it has its downsides.
Thumb Rules for async-await
Here’s a list of thumb rules that I use to stay sane while using async and await.

