Updates to sentiment, exec and range to handle missing payload properties

This commit is contained in:
dceejay
2015-03-31 08:35:56 +01:00
parent 9c22a770ef
commit 78d1da5fbc
5 changed files with 74 additions and 33 deletions

View File

@@ -23,10 +23,13 @@ module.exports = function(RED) {
var node = this;
this.on("input", function(msg) {
sentiment(msg.payload, msg.overrides || null, function (err, result) {
msg.sentiment = result;
node.send(msg);
});
if (msg.hasOwnProperty("payload")) {
sentiment(msg.payload, msg.overrides || null, function (err, result) {
msg.sentiment = result;
node.send(msg);
});
}
else { node.send(msg); } // If no payload - just pass it on.
});
}
RED.nodes.registerType("sentiment",SentimentNode);