Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs #await #map
ADD COMMENT
Topic
Name
9+6 =