Answer the question
In order to leave comments, you need to log in
Async / await arrays?
How to properly write an asynchronous array map with an asynchronous function call
//gid = [ 3417744, 3413239, 4054641, 3297954, 4818643, 4610528, 3994962 ]
let results = await gid.map((id)=> parseID(id)) // не работает
let results = await gid.map((id)=> await parseID(id)) // ошибка
Answer the question
In order to leave comments, you need to log in
Through Promise.all, and in the map function return a promise that does something with the current element
let results = await Promise.all(gid.map(async id => await parseID(id)));
As far as I remember, there is no way to sequentially through the map, only through the usual cycles, for...in for example
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question