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

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

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