MagicMirror² v2.11.0 is available! For more information about this release, check out this topic.
READ THE CHANGELOG BEFORE UPDATING!

How to load config data from file?


  • Module Developer

    @acimail01 Ok, we can fix the $ is not defined at loadJSON.

    Replace the function with the following which uses good old XMLHttpRequest:

    fuction loadJSON(filePath) {
        if (typeof module !== "undefined") {
            return require(filePath);
        } else {
            try {
                var xmlhttp = new XMLHttpRequest();
                xmlhttp.open("GET", filePath, false);
                xmlhttp.send();
                if (xmlhttp.status === 200) {
                    return JSON.parse(xmlhttp.responseText);
                } else {
                    throw "Unexpected status code!";
                }
            } catch (e) {
                console.error(e);
                return {};
            }
        }
    }