0π
β
As an extension of my comment: what youβre looking for is to actually fetch the JSON from your server using an XMLHttpRequest. You can do this in a modern, ES6-manner using the Fetch API:
fetch('/path/to/your/json')
.then(resp => resp.json())
.then(data => {
// Access the parsed JSON as `data`
console.log(data);
});
0π
If you can try using a .js file that migh work and you can structure the data the same way as in a .json file, afterall a json is just a js object, also i had this problem while doing the same thing.
DISCLAIMER: you might have to restructure your data to be in an exported variable if that is possible, like so:
export const myObj = {your json}
Source:stackexchange.com