2017-11-14 33 views
0

現在、私は1つの機能に少し問題があります。私はスイッチとして機能を作成します。しかし、msgブロックを正しい出力にルーティングすることがわかりません。ノードRED機能と複数の出力

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メッセージを見ることができますが、私は付属のデバッグ出力から任意の出力を参照してくださいすることはできません。

答えて

2

return文は、JSON.parse呼び出しに渡した関数の中にあります。したがって、Node-REDに何も返されません。

これらのリターンステートメントの代わりにnode.send([msg,null ... ]);を使用する必要があります。

関連する問題