“JavaScript vous attend” Réponses codées

Async Awiat

const data = async ()  => {
  const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  
  console.log(await got.json())
}

data();
Salo Hopeless

JavaScript vous attend

await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second wait

//or

(async () => {
await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second wait
})();
Pudochu

attendre javascrip

If the value of the expression following the await operator is not a Promise, it's converted to a resolved Promise.
Smoggy Swiftlet

JavaScript attend un mot-clé

let result = await promise;
SAMER SAEID

Async attend js

fetch('coffee.jpg')
.then(response => {
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  } else {
    return response.blob();
  }
})
.then(myBlob => {
  let objectURL = URL.createObjectURL(myBlob);
  let image = document.createElement('img');
  image.src = objectURL;
  document.body.appendChild(image);
})
.catch(e => {
  console.log('There has been a problem with your fetch operation: ' + e.message);
});
Tired Toucan

js attend

const a = async () => {	
  	await b();
  	c();
};
Solstice

Réponses similaires à “JavaScript vous attend”

Questions similaires à “JavaScript vous attend”

Plus de réponses similaires à “JavaScript vous attend” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code