Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

loop with await in js

const dummyfunction = async () => {
	for (item of items) {
      	// Until promise returns,
      	// The loop waits here!
      	await turtle();
    }
}
Comment

await loop javascript

const urls = [
  'https://jsonplaceholder.typicode.com/todos/1',
  'https://jsonplaceholder.typicode.com/todos/2',
  'https://jsonplaceholder.typicode.com/todos/3'
];

async function getTodos() {
  const promises = urls.map(async (url, idx) => 
    console.log(`Received Todo ${idx+1}:`, await fetch(url))
  );

  await Promise.all(promises);

  console.log('Finished!');
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: circular progress bar js 
Javascript :: palindrome number in javascript 
Javascript :: remove element onclick javascript 
Javascript :: execute command js 
Javascript :: find smallest length string in an array js 
Javascript :: identify primary colors in img with js 
Javascript :: yup phone number validation 
Javascript :: run node js 
Javascript :: how to pass custom regex in jquery validation 
Javascript :: create new connection in mongoose 
Javascript :: redirect to website from promise value fetch 
Javascript :: show password fa-eye javascript 
Javascript :: odd even javascript 
Javascript :: js find duplicates in array 
Javascript :: get url in javascript 
Javascript :: react router lazy load 
Javascript :: javascript insert div into another div 
Javascript :: javascript Given a base-10 integer, , convert it to binary (base-10). 
Javascript :: node sudo nvm 
Javascript :: discord.js clear console 
Javascript :: check-if-a-javascript-string-is-a-url 
Javascript :: reverse sort array of objects 
Javascript :: javascript reverse each string element in array 
Javascript :: javascript loop over three-dimensional array 
Javascript :: isChecked radio button jQuery 
Javascript :: how to create a new angular project in visual studio code 
Javascript :: Uncaught (in promise) cancel 
Javascript :: javascript find the longest string in array 
Javascript :: ex:loop array 
Javascript :: how to push key value pair to object javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =