can someone help me with this?
To avoid getting 429s errors, I need it to only run the map for the next item of the array once the result has been returned.
Te code below is logging:
START 632
START 634
START 636
Return from API inside getDifferences() [ 1057285 ]
Return from API inside getDifferences() [ 1057287 ]
Return from API inside getDifferences() [ 1057283 ]
FINISH [ 1057285 ]
FINISH [ 1057287 ]
FINISH [ 1057283 ]
I would like it to be like:
START 632
Return from API inside getDifferences() [ 1057285 ]
FINISH [ 1057285 ]
START 634
Return from API inside getDifferences() [ 1057287 ]
FINISH [ 1057287 ]
START 636
Return from API inside getDifferences() [ 1057283 ]
FINISH [ 1057283 ]
Code:
const differences = await Promise.all(products.map(async product => {
console.log('START', product)
const result = await getDifferences(product) // api
console.log('FINISH', result)
return result
}))