
Async Functions – Declares an async function, allowing use of `await` inside. Returns a Promise implicitly.
๐ Syntax
async function fetchData() {
const res = await fetch('/api');
return res.json();
}
๐งช Example
async function getUser() {
let res = await fetch('/user');
let data = await res.json();
console.log(data);
}
Comments
Post a Comment