Send payload inside a loop (for)

Hi,

I have this function (node function / Tab On Message) :

const val = msg.payload;
let file_out = {};
for (var i = 0; i < val.length/4; i++){
    file_out = {
                'name' : val[i + val.length/2]._value,
                'lat' : val[i]._value, 
                'lon' : val[i + val.length/4]._value, 
                'Date' : val[i + val.length/2 + val.length/4]._value
                }; 
msg.payload = file_out;
return msg;
}

The input is an array with four columns. My problem is that the function send just once the result while the return msg is inside the loop, so i don't understand. Maybe because i'm new...

Thank you.

Have a read of the documentation Writing Functions : Node-RED
The asynchronous section

Thx so much !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.