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

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

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