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

605
Views
Fetching json data from google apps script webapp

is there a way to get data from a google apps script webapp page without running into cors issues? I run into this when I make a get request from my app (currently running on localhost) to my appscript page. I am trying to get a list of folder names and urls. Please if anyone has an answer it will be much appreciated. Been trying to get past this nightmare for days now. See the error message below and my appscript's code

function getData() {
  var folders = DriveApp.getFolders();
  var foldersArray = [];
  while (folders.hasNext()) {
  var folder = folders.next();
  foldersArray.push([folder.getName(),folder.getUrl()])
  Logger.log(foldersArray)
}
var   json = Object.assign(...foldersArray.map(([k, v]) => ({ [k]: v })));
  console.log(json);

  return json;
}


function doGet(e){   
  var content = getData();
 return ContentService
    .createTextOutput(JSON.stringify(content))
    .setMimeType(ContentService.MimeType.JAVASCRIPT);
}

"Access to fetch at 'https://script.google.com/macros/s/AKfycbwU2jEQda0VRtIstNMcfyyGEO-aHgxRqHOdbZWwJIDcVQj7h2cTMyNUrqejuJQKBvHf_w/exec' from origin 'https://docs.google.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

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

0

I ran into a similar problem. The only way I found to solve it was to make the call to the script app from the server side, which probably means you'll just have to implement an ajax call from your client and let your server-side code proxy the request.

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!