By convention it will have a
msg.payload property containing the body of the message.
The function is expected to return a message object (or multiple message objects), but can choose to return nothing in order to halt a flow.
See the online documentation for more information on writing functions.
The function can either return the messages it wants to pass on to the next nodes in the flow, or can call
It can return/send:
- a single message object - passed to nodes connected to the first output
- an array of message objects - passed to nodes connected to the corresponding outputs
If any element of the array is itself an array of messages, multiple messages are sent to the corresponding output.
If null is returned, either by itself or as an element of the array, no message is passed on.
Logging and Error Handling
To log any information, or report an error, the following functions are available:
The Catch node can also be used to handle errors. To invoke a Catch node, pass
msg as a second argument to
Accessing Node Information
In the function block, id and name of the node can be referenced using the following properties:
node.id- id of the node
node.name- name of the node
Using environment variables
Environment variables can be accessed using