Answers for "js async 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
16

async awiat

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

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