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

257
Vistas
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 Respuestas
Responde la pregunta

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