forked from timdows/MMM-JsonTable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_helper.js
More file actions
29 lines (25 loc) · 716 Bytes
/
node_helper.js
File metadata and controls
29 lines (25 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const NodeHelper = require("node_helper");
const Log = require("logger");
module.exports = NodeHelper.create({
start () {
Log.log("MMM-JsonTable helper started...");
},
getJson (url) {
const self = this;
fetch(url)
.then((response) => response.json())
.then((json) => {
// Send the json data back with the url to distinguish it on the receiving part
self.sendSocketNotification("MMM-JsonTable_JSON_RESULT", {
url,
data: json
});
});
},
// Subclass socketNotificationReceived received.
socketNotificationReceived (notification, url) {
if (notification === "MMM-JsonTable_GET_JSON") {
this.getJson(url);
}
}
});