I am sending simultaneous multiple HTTP calls from my Angular app. I want to save the response of HTTP calls in a Map.
data: Map<number, any> = new map<number,any>();
------------------------------------------------------
this.transactions.foreach((url)=>{
this.http.post(url,{})
.map(data => this.data.set(txnNumber, data))
})
Now since HTTP requests are sent at same time and there are chances of collision in terms of retrieval and usage of Map, it would re-write it. How can we synchronize it ?