0
private async downloadAndParseData(): Promise<void>
{
    let data = await this.getData();

    let dataItemList: Item[] = [];

    for (const dataItem of data)
    {
        const tempItem: Item =
        {
            ...
        };

        dataItemList.push(tempItem);
    }
    
    for (const item of dataItemList)
    {
        ...
    }
}

In which of these loops, do I have to use for await of?

I think I have to use the await in none of them but I'm not sure...

x0tester0x
  • 49
  • 7
  • 3
    In none of them? I don't see a reason to use `for await of` anywhere here. Why do you think you need it? – VLAZ Feb 08 '21 at 09:36
  • If you have no more promises to deal with, there is no need to use await elsewhere. – Kobe Feb 08 '21 at 09:37
  • Ok, so only when I had to use an await in such a for of loop, I have to use for await of or? – x0tester0x Feb 08 '21 at 09:38
  • 1
    `for await of` will loop over async iterable. Therefore, if you don't have async iterables, you shouldn't use `for await of`. See [Using for await…of with synchronous iterables](https://stackoverflow.com/q/60706179) and [for await of VS Promise.all](https://stackoverflow.com/q/59694309) as well as https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of – VLAZ Feb 08 '21 at 09:47

0 Answers0