Overview
This node executes custom JavaScript code on a specified external server. It sends input data from the previous workflow step to the server, runs the provided JavaScript code using installed npm packages on that server, and returns the result for use in subsequent workflow steps. This is useful for scenarios where complex JavaScript logic or npm package functionality is needed but should be executed remotely, such as data transformation, calculations, or integration with external services.
Use Case Examples
- Transforming input data using lodash or other npm packages remotely.
- Performing complex calculations or data processing that require npm packages not available locally.
- Integrating with external APIs or services by executing JavaScript code on a remote server.
Properties
| Name | Meaning |
|---|---|
| Server URL | The URL of the server where the JavaScript code will be executed. |
| JavaScript Code | The JavaScript code to execute on the remote server. The code can use the input data from the previous step and must call saveOutput(data) to return results for the next step. |
Output
JSON
json- The JSON result returned from the executed JavaScript code on the remote server.
Dependencies
- Requires an external server capable of executing JavaScript code with npm packages, accessible via the provided Server URL.
- Uses HTTP POST requests to send code and context to the server and receive execution results.
Troubleshooting
- Ensure the Server URL is correct and the server is reachable from the n8n instance.
- The server must respond with a JSON object containing a 'result' property; otherwise, an error is thrown.
- If the server response is a string, it must be valid JSON; otherwise, a parsing error occurs.
- Errors during code execution on the server are caught and reported with the item index for easier debugging.