0
Q:

foreach async typescript

  for (const file of files) {
    const contents = await fs.readFile(file, 'utf8');
    console.log(contents);
  }
 
3
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 ...
})
0

New to Communities?

Join the community