Reputation: 112
I tried a lot to get data from the json file that is in inside the reactjs project folder I even tried getting json data of package.json file that is inside the reactjs folder but still got error How can I locate/get data from local JSON file I kept getting only error as output
useEffect(() => {
axios
.get("http://localhost:3000/flat-trade/package.json")
.then(function (response) {
// handle success
console.log(response + "hello");
})
.catch(function (error) {
// handle error
console.log("error");
});
});
Upvotes: 1
Views: 571
Reputation: 94
If it is local file, you can directly import into react file
import * as data from './flat-trade/package.json';
Upvotes: 3