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

514
Visualizações
GET - 404 (Not Found) Error when fetching json file

Here is the snippet of my fetch json file. There is always an error when I try to fetch the json file data.

const onSearchSubmit = (term) => {
    console.log(term);
    fetch('./JSONDATA.json', {
        method: 'get',
        headers: {
            'Content-Type': 'application/json',
            Accept: 'application/json',
        },
    })
        .then(function (response) {
            return response.json();
        })
        .then(function (data) {
            setFruits(data);
            console.log(data.term);
        })
        .catch((error) => {
            console.log(error + "json file");
        });
};

ORIGINAL SNIPPET IMAGE

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

0

The error is not related to React nor to fetch(). It says your server has responded with 404 Not Found. This means your file is not present / not reachable.

Verify with the browser (or curl) that url http://localhost:3000/JSONDATA.json exists and is reachable

Side note

'Content-Type': 'application/json' is not required, this is the request body type header, but you do not have body.

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