Dhananjay Patel Logo
  1. Home
  2. / Blog
  3. / Promis Async Await
  4. / Lessons
  5. / 5

Next

Async/Await in JavaScript

  • async and await are syntax sugars built on top of Promises to write asynchronous code in a synchronous manner.
async function fetchData() {
try {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
console.log(data);
} catch (error) {
console.error('Error fetching data:', error);
}
}
fetchData();

Next