How to handle asynchronous calls in angular. I know i am getting array as undefined due to asynchronous nature but how do i solve it
private fetchData(id){
var array = [];
this.httpClient.get('someUrl/'+id).subscribe((organisation)=>{
console.log(organisation.teams); // ['team1','team2','team3']
organisation.teams.forEach((team)=>{
this.httpClient/get('someUrl/'+team).subscribe((teamData)=>{
array.push(teamData);
})
})
console.log(array); // undefined
})
}