I am trying to make a nested Http call work in angular 6. Basically, i am trying to iterate through a for loop and make two server side calls, i want to purge the data from those two responses. Whats the easiest way to achieve this? My code below isn't working as expected.
async search() {
const stockLists = ['GOOGL', 'FB', 'ABNB', 'LULU', 'CRM']
for await(const stock of stockLists) {
await this.apiservice.GetStockOverview(stock).subscribe(async data => {
await this.apiservice.GetCurrentStockData(stock).subscribe(currenStockdata => {
data.currentStockPrice = (currenStockdata['Global Quote']['05. price']);
this.stockDataOverview.push(data);
})
})
await this.sleep(12000);
}
}
Note- i added the timer there because i can make only 5 calls per minute to this api.
thanks in advance