Код: Выделить всё
async function getSomething(parameter) {
...
}
function myFunction() {
const params = [param1, param2, ...]
const results = []
let i = 0
params.forEach((param) => {
getSomething(param).then((result) => results[i++] = result)
})
console.log(results)
}
Как мне дождаться, пока все обещания в цикле for будут выполнены? решено?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -in-a-loop
Мобильная версия