Sending Values from NodeRed to Grafana with SimpleJSON

Im trying to send the values of a sensor to Grafana via NodeRed with the help of SimpleJSON Plugin.

This is my NodeRed Flow

And my functions are
1st:

tmp = [];
tmp.push(parseFloat(msg.payload));
tmp.push(parseInt(new Date().getTime()));

flow.set('speed', tmp);
node.status({'text': msg.payload});
return msg;

2nd:

tmp = [];

for(var id in msg.payload.targets){
    var tmp_target = {};
    tmp_target['target'] = msg.payload.targets[id].target;
    tmp_target['datapoints'] = [flow.get('speed')];
    
    out.push(tmp_target);
}
msg.payload = JSON.stringify(out);
return msg;

I followed this guy’s video
Video

On Grafana I get this error

Has anyone ever tried this ?


Made a GET request with speed. I got the payload

when im tryin to post it says that out is not defined even though it is <- FIXED THAT MY MISTAKE

The payload of the “posted” message payload is empty

Also I cannot understand why Grafana gives me Bad Request