Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 542 Bytes

File metadata and controls

20 lines (15 loc) · 542 Bytes

JavaScript

Multiple async requests

rPromises = [...Array(100).keys()].map((i) =>
  // prettier-ignore
  fetch(`https://jsonplaceholder.typicode.com/posts/${i + 1}`)
    .then(r => r.json())
    .then(data => console.log(`Completed one: ${new Date().getTime()}`))
    .catch((err) => console.error(`We've got and error over here: ${err}`))
);

// prettier-ignore
Promise.allSettled(rPromises)
  .then(() => console.log(`Completed all: ${new Date().getTime()}`))
  .then(() => console.log('After all is completed'))