I am trying to use forEach in array of object and based on the following condition send a request and get that response for using in the other call. Here is the code:
products.forEach(product => {
if (
product.type === 'shows' &&
product.isSoldOut &&
product.otherData
) {
delete product.brand.brandId
product.brand.isTop = true
const res = apiService.create(product.brand)
console.log(res)
}
})
When I add await const res = await apiService.create(product.brand)
here it shows a warning too. How can I use async await in this scenario or is there other way to overcome this issue?