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

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

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