I have to await for a subscription in a for loop and then utilize the resultant response outside the loop but it is not awaiting.
function abc() {
this.array = someValueInitialized;
this.array.forEach(data => {
this.apiCall.subscribe(resp => {
console.log("A");
data.updatedValue = resp.value;
});
});
console.log("B");
this.array.updatedValue; //undefined
}
The flow of execution is B
then A
as its not awaiting.
I tried with .toPromise()
as well, but that gives ZoneAwarePromise response.