Async and Await in JavaScript
Async and Await in JavaScript
async Keyword
- The async keyword is used to declare a function that
always returns a promise.
- Even if the function does not explicitly return a
promise, it automatically wraps the return value in a
promise.
await Keyword
# Example:
javascript
async function fetchWithErrorHandling() {
try {
} catch (error) {
}
}
fetchWithErrorHandling();
let getData = async ()=>{
try{
// console.log(data)
getData()