1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Don't log when all is good, parse JSON retun

This commit is contained in:
Glyn Hudson 2015-10-26 00:47:55 +00:00
parent 1467575f6c
commit dc3c1b7cc4
2 changed files with 4 additions and 8 deletions

View File

@ -58,7 +58,6 @@ module.exports = function(RED) {
}
node.log("[emoncms] "+this.url);
http.get(this.url, function(res) {
node.log("Http response: " + res.statusCode);
msg.rc = res.statusCode;
msg.payload = "";
if ((msg.rc != 200) && (msg.rc != 404)) {
@ -75,7 +74,6 @@ module.exports = function(RED) {
// node.error(e);
msg.rc = 503;
msg.payload = e;
node.send(msg);
});
});
}
@ -101,16 +99,15 @@ module.exports = function(RED) {
if (feedid !== "") {
this.url += '&id=' + feedid;
}
if (typeof msg.time !== 'undefined') {
this.url += '&time=' + msg.time;
if (typeof msg.payload !== 'undefined') {
this.url += '&time=' + msg.payload;
}
node.log("[emoncms] "+this.url);
http.get(this.url, function(res) {
node.log("Http response: " + res.statusCode);
msg.rc = res.statusCode;
msg.payload = "";
if ((msg.rc != 200) && (msg.rc != 404)) {
node.send(msg);
node.send(JSON.parse(msg));
}
res.setEncoding('utf8');
res.on('data', function(chunk) {
@ -123,7 +120,6 @@ module.exports = function(RED) {
// node.error(e);
msg.rc = 503;
msg.payload = e;
node.send(msg);
});
});
}

View File

@ -32,4 +32,4 @@ Insertion time can be manipulated by setting **msg.time**.
### Emoncms In:
Fetches last emoncms feed value in JSON format, use JSON processor node to convert to number.
Fetches last emoncms feed value, returns numberical value.