Skip to content

Async Functions

Async functions (declared with async) allow writing asynchronous code using await to pause execution until a Promise settles. They always return a Promise, making them ideal for handling asynchronous operations.

async function fetchData() {
const response = await fetch("https://api.example.com");
const data = await response.json();
return data;
}
/