You need to enable javascript to run this app response when try to access local json file in react You need to enable javascript to run this app response when try to access local json file in react reactjs reactjs

You need to enable javascript to run this app response when try to access local json file in react


I am not sure what you mean by trying to access a local json file. You can not access files on the device that runs the webpage if that is what you mean by local files. You can only access to files that are on the webserver that is serving your applications which are in directory of your application. I assume the second case and assume you have file called fakedata.json at the top directory of your application. In order to access that file you can use import as following:

import myJsonFile from "./fakedata.json"

If you want to use fetch to dynamically load, you should put ./ at the beginning as

fetch('./fakedata.json')

so that it fetches a file called fakedata.json which is located at the root directory.


I received this message when no proxy to the server was specified inside client package.json file.

"proxy": "http://localhost:5000"

(Assuming the server was setup to listen on port 5000. In my case it also required server restart once added)


I was facing similar issues.

I had put the below code just after app.use

app.get('/*', (req, res) => {   res.sendFile(path.join(__dirname, '/../', 'build', 'index.html'));});

which served all the API requests directly.

Maybe this can help others facing this issue.