-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnode_helper.js
More file actions
35 lines (29 loc) · 830 Bytes
/
node_helper.js
File metadata and controls
35 lines (29 loc) · 830 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
30
31
32
33
34
35
/* Magic Mirror
* Module: MMM-Events
*
* By Mykle1
*
*/
const NodeHelper = require('node_helper');
const request = require('request');
module.exports = NodeHelper.create({
start: function() {
console.log("Starting node_helper for: " + this.name);
},
getEvents: function(url) {
request({
url: url,
method: 'GET'
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
var result = JSON.parse(body).events;
this.sendSocketNotification('EVENTS_RESULT', result);
}
});
},
socketNotificationReceived: function(notification, payload) {
if (notification === 'GET_EVENTS') {
this.getEvents(payload);
}
}
});