0

I am trying to load JSON locally but it give me error of file not found (404). I have tried following

  • renaming the json file
  • trimming down JSON to see if there was a error there

Following is my folder structure and my JSON file structure


    {
        "id": "1",
        "name": "Lorem, ipsum.",
        "image": "./src/assets/1.jpg",
        "desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsam, neque."
    }

Error error

localhost
  • 822
  • 2
  • 20
  • 51

1 Answers1

0

Relative URLs, in client-side JavaScript, are resolved relative to the URL of the HTML document the script is running in.

They are not resolved relative to the URL of the JS file.

Your JSON file is in the same directory as the JS file, but the URL you are asking for is looking for it in the same directory as the HTML file… which is one level up.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335