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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay