Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
$http get loop append response data together

I have a list of links, with a number in each one from 1 up to however many there are. My goal is to write a for loop, that goes through each link, runs a HTTP get, then saves the response data to an array object. I have tried various methods, but its difficult because of the fact that I am dealing with $scope variables, so none of the methods I find work.

for (let i = 0; i < 1000; i++) {
  $http.get("Start of URL"
+ i +  "End of URL")
  .then(function (response){
    $scope.datasingle = response.data;
  }); 
  $scope.datacombined = ??  

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this way;

const promisses = [];
for (let i = 0; i < 1000; i++) {
  promisses.push( new Promise(function (resolve, reject) {
    $http.get("Start of URL"+ i +  "End of URL").then(function(response){
      resolve(response.Data);
    });
  }));
}

Promise.all(promisses).then(function (values) {
  console.log(values); //you will get all the resolved result in this array and do what you want
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!