i've a similar situation
array.forEach(item => {
function_fetch(item)
})
now i need that before that loop continue he await that the function end and do what have to do, then recall the function with the other item
i've a similar situation
array.forEach(item => {
function_fetch(item)
})
now i need that before that loop continue he await that the function end and do what have to do, then recall the function with the other item
You can not use await in forEach function directly.
So you can use simple for of loop.
async function fetching () {
for ( const item of array) {
await function_fetch(item)
}
}
await function should be inside any async function only.