JavaScript Async/Await

A function that is declared with the async keyword returns a Promise .

Within an async function, the await function waits for a Promise to be resolved before moving on to the next line of code.

Async will call code asynchronously and await make it wait for promise to get resolved .

Output: Shrikant

In above example , startCall method gets invoke which asynchronously call the  fetchIt function .

 it will wait for getting success or fail response. once returned success , the value is  set to  paragraph element in HTML.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top