JSFiddle - React, Tailwind, and code Playground

by Csaba Hellinger

JavaScript

function fetch() {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve('data');
    }, 2000);
  });
}

async function asyncCall() {
  console.log('calling');
  var result = await fetch();
  console.log(result);
}

asyncCall();