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

142
Views
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 answers
Answer question

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 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!