Are Promises Still Used with the Introduction of async/await?

async/await has significantly simplified the usage of promises and allows us to write asynchronous code that looks like synchronous code.

When using async and await, much of the complexity of promises (and sometimes even their very presence!) disappears.

So are promises still in use?

Under the hood, async/await still relies on promises. When you use await within an async function, it awaits the resolution of a promise and then returns the resolved value. If the promise is rejected, it throws an error that can be caught using a try/catch block.

In essence, async/await builds upon promises. To truly master async/await, it is essential to have a solid understanding of promises.

Also, promises are used directly when more fine-grained control or composition of asynchronous operations is required.

For example, let’s say you have three asynchronous calls you need to make. Two of them A and B are independent, and the last C cannot be executed until the both have finished.

You can just use await and execute them serially:

await A;
await B;
await C;

Image1


Or you could use Promises:

await Promise.all([A, B]);
await C;

Image2


I've developed a guide called Master JavaScript Promises. It's a beginner-friendly guide with one goal: to help you build your intuition of how Promises works, so that you can work with async functions confidently.

-> Master JavaScript Promises

Get my free, weekly JavaScript tutorials

Want to improve your JavaScript fluency?

Every week, I send a new full-length JavaScript article to thousands of developers. Learn about asynchronous programming, closures, and best practices — as well as general tips for software engineers.

Join today, and level up your JavaScript every Sunday!

Thank you, Taha, for your amazing newsletter. I’m really benefiting from the valuable insights and tips you share.

- Remi Egwuda