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

258
Visualizações
How can I Fetch data from a URL using javascript

My requirement is to get the data on a page with URL example: https://www.blogger.com/about/ I am able to do so using appscript code at compilation level in code.gs as shown below:

function getPTtrack(linksArray){
  linksArray = `https://www.blogger.com/about/`;
  var ptTracknames = [];
  for(var sear in linksArray){
       var optoutlink= linksArray[sear].toString().search("Publish your passion");
   if(optoutlink!=-1){
  var x = linksArray[sear].replace(">.","").replace("<","").replace(">","").toString();
  var page = UrlFetchApp.fetch(x).getContentText(); 
  var number = page.match(/<b>(.*)<\/b>/)[1];
  Logger.log(number);
  ptTracknames.push(number);
  }
  }
  console.log(ptTracknames);
  return ptTracknames;
}

This leads to delay in getting the output . To reduce loading time I would need to write the same code in javascript which can give output in run time. So if any one know which function can be used in javascript instead of the following function used in appscript.

UrlFetchApp.fetch(x).getContentText(); 

I have come across various methods in stackoverflow which returns the value in JSON . I would like to get the value in text instead of a json value.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

A simple fetch returns everything you need. You can then extract the data as JSON as you mentioned, or as a string if that serves your purpose.

String:

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.text())
  .then(data => console.log(data));

JSON:

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.text())
  .then(data => console.log(data));
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