Load local json file

11-01-2022 05:19 PM
Occasional Contributor III

What's the recommendation to where to place a json file in the ExB file structure and how to access it with the local pathname.

I am using fetch to read the json file but it seems that I cannot to access it if I use a local file.

1 Reply
Occasional Contributor III

For anyone who may have the same question, this is what I did

I placed my data folder under the src/runtime and instead of fetch, I used 

import data from "./data/info.json";

 If you run into issues accessing your json file, then add this:

 const loadedData = JSON.stringify(data);
    const json = JSON.parse(loadedData);


0 Kudos