What is wrong with this?

IF YOU KNOW - JUST LIKE THE POST -DONT GIVE OUT THE ANSWER :slight_smile:

I was working on real flow late last night and needed to change from outputting on payload to payload.text to feed the mastodon node instead of the twitter node

I spent an hour tearing my hair out as to why it wasn't working and had to resort to an external change node :slight_smile:

Can't believe after all the years working with NR that it was only when I wrote this simple flow that my errant thinking struck me. :slight_smile:

Although, I am still suprised that it silently "fails" and doesn't give an error - why is that?

FYI here is the JS that the Blocky node generates

image

If you added the following (exactly as written...) to the top of that code it wouldn't fail silently.

"use strict";

why is that?

Welcome to JavaScript. :wink:

Do I get a prize for spotting more than 1 error in that code :wink:

You can speak Blockly? :slight_smile:

I can but the error is in the output javascript.

That's just what Blocky transcribes it to - can't control that - don't care - hate JS :slight_smile:

My initial answer to "What's wrong with this" was the colour clash and horrible shapes of the Blockly code. Not all non-procedural languages can have the clean UI of Node-red though.

I tried to see who did know and "liked" the post; I accidentally liked it myself.
Yet I have not the slightest idea what's wrong with the code apart from it just feels wrong.

I followed knolleary's hint of adding "use strict"; to the Javascript, it still fails silently.

Please put me out of my misery and explain what's going on?

It doesn't set msg.payload to an object
So when it tries to set msg.payload.text - it just gets ignored and the original timestamp msg.payload gets sent on instead

This fixes it

Interesting :slight_smile:

Arrghhhhh! You added some pink to all that claret and magenta. It hurts!

Thanks for the explanation.