DEV Community

DB_Cooper23
DB_Cooper23

Posted on

Async/Await Keyword

What will happen if Await keyword is not used?

Top comments (4)

Collapse
 
saimwebhr profile image
Muhammad Saim Hashmi

If you don't await the specific task, the async response is lost. If you await the task, its async response is fetched properly. As a best practice, you should always await the async calls.

Collapse
 
bolendra profile image
DB_Cooper23

What about the code which is written inside Async keyword? Will it run accordingly, the way it was running when using async & await keyword?

Collapse
 
saimwebhr profile image
Muhammad Saim Hashmi • Edited

Yes, It'll execute line by line. But for instance, if you want to execute more than 2 async calls(Like you want two or more await keywords to be used in 1 async function), then it may vary with respect to processing and computation. The best is to use Promise.All to execute multiple async calls line by line.
Example:
Promise.all([promise1, promise2, promise3])

Thread Thread
 
bolendra profile image
DB_Cooper23

Thanks Brother