-
Notifications
You must be signed in to change notification settings - Fork 2
/
node_helper.js
29 lines (20 loc) · 958 Bytes
/
node_helper.js
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
var request = require('request');
var NodeHelper = require("node_helper");
module.exports = NodeHelper.create({
start: function() {
console.log("Starting node helper: " + this.name);
},
socketNotificationReceived: function(notification, payload) {
var self = this;
console.log("Downloading recipes with signal: " + notification + " From URL: " + payload.url);
if(notification === "GET_RECIPE"){
var recipeJsonUri = payload.url;
request(recipeJsonUri, function (error, response, body) {
if (!error && response.statusCode == 200) {
// console.log(body);
self.sendSocketNotification("RECIPE", JSON.parse(body));
}
});
}
},
});