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

193
Views
$http get loop agregar datos de respuesta juntos

Tengo una lista de enlaces, con un número en cada uno desde 1 hasta tantos como sean. Mi objetivo es escribir un bucle for, que pase por cada enlace, ejecute un HTTP get y luego guarde los datos de respuesta en un objeto de matriz. He probado varios métodos, pero es difícil por el hecho de que estoy tratando con variables de $scope, por lo que ninguno de los métodos que encuentro funciona.

 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

Prueba de esta manera;

 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!