Answers for "callback async await promise"

5

promise.all async await

async function fetchABC() {
  const [a, b, c] = await Promise.all([a(), b(), c()]);

}
Posted by: Guest on April-20-2020
0

await callback

function apiOn(event) {
  return new Promise(resolve => {
    api.on(event, response => resolve(response));
  });
}
Posted by: Guest on December-26-2020
0

promise async await

async function myFetch() {
  let response = await fetch('coffee.jpg');
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }
  return await response.blob();

}

myFetch().then((blob) => {
  let objectURL = URL.createObjectURL(blob);
  let image = document.createElement('img');
  image.src = objectURL;
  document.body.appendChild(image);
}).catch(e => console.log(e));
Posted by: Guest on October-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language