Read the statement by Michael Teeuw here.
Compliments: RemoteFile Configuration
-
@jacktar said in Compliments: RemoteFile Configuration:
compliments.js:134 GET http://0.0.0.0:8080/modules/default/compliments/file://home/pi/MagicMirror/compliments.json 404 (Not Found)
You see the problem in the error message.
The variableremoteFile
gets appended to an existing path which is http://0.0.0.0:8080/modules/default/compliments/.You only need to put in the name of the file without a path and put your file into the compliments folder.
-
@jacktar Here is the underlying function
/* complimentFile(callback) * Retrieve a file from the local filesystem */ complimentFile: function (callback) { var xobj = new XMLHttpRequest(), isRemote = this.config.remoteFile.indexOf("http://") === 0 || this.config.remoteFile.indexOf("https://") === 0, path = isRemote ? this.config.remoteFile : this.file(this.config.remoteFile); xobj.overrideMimeType("application/json"); xobj.open("GET", path, true); xobj.onreadystatechange = function () { if (xobj.readyState === 4 && xobj.status === 200) { callback(xobj.responseText); } }; xobj.send(null); },
Whenever you use a “http://” or “https://” path it takes the path as you have provided. If not it converts it to an absolute path using the
this.file(this.config.remoteFile)
method. This method uses the modules directory (like you can see in my post above) and appends the path you have given -
@lavolp3 another thing to say is
the MagicMirror provided web server assumes
modules is the root
express is listening/watching for modules as the base pathhttp://localhost:8080/modules/…
the file can be anywhere further down
-
Ok, thanks. Got that sorted now :)
Hopefully this will help others with the same dilemma.
I had read a post referencing the use offile://
notation which, apparently, is a red-herring.Just for clarity to others, a local
compliments.json
file should be located in/pi/MagicMirror/modules/default/compliments/
directory and referenced using only the file name in the config file.e.g.
remoteFile: 'compliments.json'
-
@jacktar said in Compliments: RemoteFile Configuration:
Just for clarity to others, a local compliments.json
file should be located in /pi/MagicMirror/modules/default/compliments/ directory and referenced using only the file name in the config file.
e.g. remoteFile: ‘compliments.json’So… what happens if we update the compliments module? Do our customizations in the compliments.json file get wiped out?
can we put the compliments.json somewhere else to protect it? -
@kayakbabe yes they will be lost.
.NEVER edit the source files we provide.the design is that all your setting go in config.js
and custom.css for colors etc.module :"compliments", position:"....", config:{ compliments:{ morning:[], afternoon:[], etc } }
-