Writing Functions
Writing Functions
Writing Functions
The Function node allows JavaScript code to be run against the messages that are
passed through it.
Other nodes may attach their own properties to the message, and they should be
described in their documentation.
Writing a Function
The code entered into the Function node represents the body of the function. The
most simple function simply returns the message exactly as-is:
return msg;
If the function returns null, then no message is passed on and the flow ends.
The function must always return a msg object. Returning a number or string will
result in an error.
The returned message object does not need to be same object as was passed in;
the function can construct a completely new object before returning it. For example:
Use node.warn() to show warnings in the sidebar to help you debug. For example: