node-redkepserverex

Why does only one value gets return in NodeRED function node?


I have a NodeRED flow which has a function node and my code is following

var left = { payload : msg.payload.readResults[0].v };
var right = { payload : msg.payload.readResults[1].v };
node.warn(left);
node.warn(right);
if(left || right)
{
    return [left,right];
}

Here I'm trying to get the both left and right outputs. The node.warn(left) and node.warn(right) tags give the outputs correctly but in the real return statement it outputs only left value when I have return[left,right]. When I have return left,right it returns right value.

How to get the both left and right values using return statement? Thank you!

enter image description here


Solution

  • Finally figured it out, posting if incase anyone interested!

    var left = {payload : msg.payload.readResults[0].v };
    var right = {payload : msg.payload.readResults[1].v };
    
    
    return [[left,right]];