Answers for "await inside map js"

3

await array of promises

await Promise.all(arrayOfPromises)
Posted by: Guest on April-08-2020
2

await inside map js

const mapLoop = async _ => {
  console.log('Start')

  const promises = fruitsToGet.map(async fruit => {
    const numFruit = await getNumFruit(fruit)
    return numFruit
  })

  const numFruits = await Promise.all(promises)
  console.log(numFruits)

  console.log('End')
}
Posted by: Guest on July-20-2020
1

nodejs await inside map

const someFunction = (myArray) => {
    const promises = myArray.map(async (myValue) => {
        return {
            id: "my_id",
            myValue: await service.getByValue(myValue)
        }
    });
    return Promise.all(promises);
}
Posted by: Guest on February-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language