Trying to load a JSON file

I’m trying to follow

To display the results from a JSON file, so first things first and am trying to load the object into a variable

var content = file_get_contents("../data/cooling-areas.json");


but If I check if the URL exists
I see
So if the file exists, why would the variable be undefined?

You try to use PHP function in JS?

1 Like

The error is not referring to the file, but the function. Are you sure all your dependencies are loading, otherwise you need to write the import function in your cooling_areas.js file.

something similar to:

function file_get_contents(filename) {
    fetch(filename).then((resp) => resp.text()).then(function(data) {
        return data;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.