DEV Community

Cover image for Async Await Keywords in JavaScript - Make Asynchronous Code Look Synchronous
Ankit Tanna
Ankit Tanna

Posted on

2

Async Await Keywords in JavaScript - Make Asynchronous Code Look Synchronous

What is Anync Await Keyword?
In JavaScript, we have used promises and the code of promise looks like an asynchronous code.

We can make asynchronous code look like a synchronous code by using async await keywords.

Definition:
Inside a function marked as async, you are allowed to place the await keyword in front of an expression that returns a promise. When you place await keyword, the execution of async function is paused until the promise is resolved/rejected.

Have a look at this tutorial which shows how to transform an asynchronous fetch api call to a synchronous looking(yet asynchronous) code.

It will also show you the difference between Promises and Async/Await and which one's better.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay