i have a bit of situation with executing procedure after async call to backend api
this.includedServicesList.forEach(x =>
this.ccApi.getServicePrice(x.ServiceCode, '0', 'NONE')
.subscribe(data => {
x.ServicePrice = data.MPrice;
this.includedServicesPrice += data.MPrice;
//this.calculatePrices();
})
);
//this.calculatePrices();
For each element of array I need to call backend api (get some data from database).
After that is done I would like to call calculatePrices procedure to update data. If I put procedure call after forEach loop, it just gets executed before data is even gathered. If I put it inside subscribe block, it gets called once for each element in array (and I need it called only once after entire loop is done)
Is there any good way to solve this (without setting random timeouts and hoping all async calls will be done by that point or stuff like that)
Thank you in advance