Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

607
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda