Answers for "explain `async` and `await`"

20

async await

const data = async ()  => {
  const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  
  console.log(await got.json())
}

data();
Posted by: Guest on July-24-2020
0

async and await

try {
  const result = await makeHttpRequest('google.com');
  console.log(result);
} catch (err) {
  console.log('Oh boy, an error');
}
Posted by: Guest on January-30-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language