What is Async & Await?
In JavaScript, developers use the async and await keywords together to handle asynchronous operations in a more synchronous and readable manner. ECMAScript 2017 introduced these features.
JavaScript’s async and await make promises easier to write. The async keyword makes a function return a Promise, while the await keyword makes a function wait for a Promise.
Async
Place the async keyword before a function declaration to indicate that the function is asynchronous. This allows the function to implicitly return a Promise. Inside an async function, you can use the await keyword to pause the function’s execution until a Promise resolves or rejects.
Await
You can only use the await keyword inside an async function. Place it before a Promise or an expression that returns a Promise. When you encounter an await statement, pause the execution of the async function until the Promise settles (resolves or rejects). While waiting for the Promise to resolve, other code can run in the meantime.