How to handle asynchronous operations with async/await in javascript?

The async and await keywords enable asynchronous, promise-based behavior in a clearer syntax.

Example:


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

  fetchData();
  

Beginner's Guide to JavaScript