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

129
Views
JavaScript fetch outputting error in console
fetch('info.json').then(function (response) {
  return response.json();
}).then(function (obj) {
  console.log(obj);
}).catch(function (error) {
  console.error('Something went wrong with retrieving the info!');
});

The file 'info.json' is in the same directory as this javascript file, and when I run it on chrome using dev tools, the console outputs 'Something went wrong with retrieving the data!' I'm not sure how to fix this as this is my first time working with developer tools and unloading a package via extensions on chrome. Any help would be appreciated! For those curious, I'm trying to create an autofiller for a site and the 'info.json' file contains info like name, address, etc.

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

0

This will make a request to https://example.com/info.json

You need to put this in your manifest:

  "web_accessible_resources": [
    "yourfolder/*"
  ],

Then in your script get the url

const myUrl = chrome.runtime.getURL('yourFolder/info.json')

fetch(myUrl).then(function (response) {
  return response.json();
}).then(function (obj) {
  console.log(obj);
}).catch(function (error) {
  console.error('Something went wrong with retrieving the info!');
});

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!