Mills
Mills

Reputation: 57

d3.js 404 json file not found

I am trying to use d3.js example code here: https://bl.ocks.org/ChumaA/385a269db46ae56444772b62f1ae82bf

In this case I am using view jade/express/node to load it, however I am getting a 404 error for the mockelasticdata.json file, I believe I am routing it correctly. I provided photos to show the directory path and the chrome console error.

Console Error: console error

Directory Path: directory path

edit: here is the json call using d3 to read the data

      d3.json('src/mockelasticdata.json', function(error, mockdata) {
          if (error) return console.error(error);
          console.log('mockdata',mockdata);
          mapdata = mockdata;
          draw(mockdata)
      });

Upvotes: 2

Views: 3344

Answers (1)

Trenton Trama
Trenton Trama

Reputation: 4930

You're trying to access a file in the src directory. After your project is built and run, that directory doesn't exist.

Move the JSON file into the public directory. This is where all static, unrouted files will be served from.

Upvotes: 3

Related Questions