Unable to load json data file

I am getting below alert while publishing via git hub.
But works fine in my local

I am using jquery plugin

JSON file is not getting loaded
I find below error in console.

Failed to load resource: the server responded with a status of 404 ()

Hey can you please share your code in a code sandbox or codepen so we can debug ?


Not enough details, but I’d say the path isn’t correct, or you didn’t add/commit/push the file.

  1. Check out that the file is in the remote repository,
  2. If it is, check the path to the file.

I had imported project from git to codesandbox.
Please find the url below,

It gives some dependencies error, though its added.

I guess this won’t work if you don’t run

npm run build

before uploading.

I find repl.it easy to set up, cause I don’t see any console on that website. You can upload it to repl.it, and you don’t need to do any command line thing on this case.

It’s the “-” package you have added. Not sure what that is supposed to be?

It does seem to be working on Codesandbox, as far as I can tell, does it not?

I downloaded your page and runs fine here…

Is that what you were expecting?

If that’s the case, I would remove the node_modules and re-install using npm i

Otherwise, I guess it’s a problem with something more complicated (related to github).

I got it working as a github page now.

Don’t worry, will remove it after you check it out. :slight_smile:

I just changed this line:

      url:'./resumeData.json',  // <-----added a dot here ./
      cache: false,
      success: function(data){
        this.setState({resumeData: data});
      error: function(xhr, status, err){

Possible Explanation
For the computer / means start from the root, so it was not finding the file on the root folder. That probably works removing ./ or / altogether, but I didn’t test.

If you are just going to have a static JSON file it seems a bit unnecessary to perform an ajax call. Why not just import and use it?

1 Like

it can’t be done, unless you change the extension, right?

(cause she needs it on a javascript file and import or require ‘x.json’ won’t work.)

but still, changing the extension and importing it is not that difficult, and will perform better…