How to organize the function node? IBM Watson

Hello friends! I'm currently doing a project sending data from Watson IBM IoT to Cloudant through Node-Red, however, the data arrives in the database all separately, like in the photo.


I would like to know how I can organize them into one. Can you help me?

You need to put a Debug node before and after the function node - see what is going into your function then you should understand.

1 Like

is there the debug before the function:

And after:

Can you help me please @Steve-Mcl ?

As you can see the values come through separately.

I would suggest the following...

After the IBM iot node, put a switch node to test msg.topic is == to one of the 7 topics you are interested in. Then feed all 7 outputs of the switch node to a join node set for manual mode, key/value mode, 7 parts, subsequent values.

Once you have that working you should see all values in one message & you can used the "copy path" method I showed you before - to build 1 object.


See this article in the cookbook for an example of how to join messages into one object.

1 Like

Apparently it worked, but how do I get the values ​​from this place in the function? I tried here and it's not going the way I tried... Can you help me with this last step?



@Steve-Mcl

Use "copy path" button on the property in the debug message.
then paste it into your function code (pre-pend with msg.)


There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages


There are tonnes of tip and tricks - I always recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like


Really thanks @Steve-Mcl ! Thanks for helping me like this through links, instead of copying, I learned. Thank you very much :slight_smile:

2 Likes

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