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

138
Vistas
ImportJson() print the data only when I return the function in Google App script

I want to implement a Loop on ImportJson() but it doesn't work without return

The Code from this github link :ImportJson Into Google Sheets I made a new function

This's Work but it prints only 1 API call for sure because of return

function ImportData1() {

  veunueid_arr = ["KovZpZA7AAEA", "KovZpa2gne"];



  for (var Veunue_id1 = 0; Veunue_id1 < 2; Veunue_id1++) {

    var url = "https://app.ticketmaster.com/discovery/v2/events.json?venueId= " + veunueid_arr[Veunue_id1] + "&apikey=" + API_key + "&locale=*";


    //  console.log("Veuneid" + Veunue_id + Venue_Id_List.length);
    console.log("ImportData1();" + Venue_Id_List.length);

     return ImportJSON (url, "/_embedded/events/name", "noInherit,noTruncate,rawHeaders" );

     
  }
 

}

This's doesn't work because I didn't use return! So It should print the data even without Return but it doesn't

function ImportData1() {
    
      veunueid_arr = ["KovZpZA7AAEA", "KovZpa2gne"];
    
    
    
      for (var Veunue_id1 = 0; Veunue_id1 < 2; Veunue_id1++) {
    
        var url = "https://app.ticketmaster.com/discovery/v2/events.json?venueId= " + veunueid_arr[Veunue_id1] + "&apikey=" + API_key + "&locale=*";
 
    
        //  console.log("Veuneid" + Veunue_id + Venue_Id_List.length);
        console.log("ImportData1();" + Venue_Id_List.length);
    
          ImportJSON (url, "/_embedded/events/name", "noInherit,noTruncate,rawHeaders" );
    
         
      }
     
    
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I assume you want to join results from several urls in one big list. You can use Array.concat, like this

function ImportData1() {    
  veunueid_arr = ["KovZpZA7AAEA", "KovZpa2gne"];
  var results = [];    
    
  for (var Veunue_id1 = 0; Veunue_id1 < 2; Veunue_id1++) {   
    var url = "https://app.ticketmaster.com/discovery/v2/events.json?venueId= " + veunueid_arr[Veunue_id1] + "&apikey=" + API_key + "&locale=*";
 
    results = results.concat(ImportJSON(url, "/_embedded/events/name", "noInherit,noTruncate,rawHeaders" ));             
  }    
 return results;
}
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