Answers for "array.foreach async"

1

async foreach

[1, 2, 3].forEach(async (num) => {  await waitFor(50);  console.log(num);});console.log('Done');
Posted by: Guest on September-15-2020
0

typescript foreach async await

export async function asyncForEach<T>(array: Array<T>, callback: (item: T, index: number) => void) {
        for (let index = 0; index < array.length; index++) {
            await callback(array[index], index);
        }
    }

await asyncForEach(receipts, async (eachItem) => {
    await ...
})
Posted by: Guest on October-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language