节点RED功能和多个输出

时间:2017-11-14 08:55:05

标签: function node-red

目前我对一个功能有点问题。我将创建一个函数作为开关。但是我无法看到我将msg块路由到正确的输出。

payloadJSON = JSON.parse(msg.payload, (key, value)=> {
  if(key == "changeType") {
    if (value === "create" ) {
        node.error('In: ' + value);
        return [ msg, null, null, null ];
    }else if(value === "update" ) {
        node.error('In: ' + value);
        return [ null, msg, null, null ];
    }else if(value === "delete" ) {
        node.error('In: ' + value);
        return [ null, null, msg, null ];
    }else{
        node.error('In: ' + "otherwise");
        return [ null, null, null, msg ];
    }
  }
});

是我在功能

中配置了4个输出

我可以在日志中看到node.error消息,但是我看不到附加的Debug Output中的任何输出。

1 个答案:

答案 0 :(得分:3)

您的返回语句位于您传递给JSON.parse调用的函数内部 - 因此它们不会向Node-RED返回任何内容。

您需要使用node.send([msg,null ... ]);代替那些返回语句。

相关问题