What is async / await?
Syntactic sugar over Promises for cleaner asynchronous code.
async function fetchData() {
try {
const res = await fetch('/api/data');
const data = await res.json();
console.log(data);
} catch (err) { console.error(err); }
Syntactic sugar over Promises for cleaner asynchronous code.
async function fetchData() {
try {
const res = await fetch('/api/data');
const data = await res.json();
console.log(data);
} catch (err) { console.error(err); }