Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
$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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda