Select to view content in your preferred language

Load local json file

614
1
11-01-2022 05:19 PM
LefterisKoumis
Frequent Contributor

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
LefterisKoumis
Frequent Contributor

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