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

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

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


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')];
msg.payload = JSON.stringify(out);
return msg;

I followed this guy’s 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