Search code examples
node.jsfilenode-redpayload

node-red use several sources to build http post request


I am new to node-red and I am confused with the "message payload flow system".

I want to send a POST request that contains, among other params, files into the request payload. These files should be in an array called "files".

I read my files from my file system, this works fine, but in the function node, how do I build my POST payload?

So far I have this: enter image description here

The problem is that the payload contains both files and I can't find a way to get them separately. How can I retrieve both my files, separately, into the BUILD-POST-REQ function?


Solution

  • The core Join node can be used to combine the output of parallel input streams. It has a number of modes that control how many input messages it will collect together.

    enter image description here

    These include a count of messages.

    You can also choose how it combines the input messages, this can be as an array or as an object using the msg.topic as the key to the incoming msg.payload