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

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

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