I have this code:
let [totalPromos, setTotalPromos] = useState(0);
for (let item of cart.items){
let response = await api.get('/products/' + item.id);
let price = response.data.price;
let promotion = response.data.promotions[0];
setTotalPromos(totalPromos + 1);
}
I have 2 items in cart, that I call an api with axios to reach its promotion. I am not able to sum the total of promos of my products. The value is getting only the final value like in this code, which is 1. What I am doing wrong?