B
B
bogdan_nsk2020-04-24 13:28:46
Angular
bogdan_nsk, 2020-04-24 13:28:46

How to send multiple api requests in a loop in angular?

I want to make several api requests through a loop. But outputs only 1 request correctly. There are more of them. Please tell me how to solve this problem

for(let i = 0; i < Object.keys(response).length ; i++){
     
          return this.facebookService.getDataOfAds(response[i][2])
         .toPromise().then(response => {
           
          this.data = this.ls.addItem(response,this.varGroup);
         
         })
         .catch((err:any) => {
            console.log(err);
         }); 
      }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question