Skip to main content

Code Node (type = "code")

Executes custom JavaScript logic and transforms the context arbitrarily.

Schema

  • See: CodeNode.json
  • Key fields:
    • data.inputs: input schema
    • data.inputsValues: input sources
    • data.script: script (language / content)
    • data.outputs: output schema

Example

Script entry function:

async function main(params) {
return {
ok: true,
echo: params
};
}

Convert HTTP response into End output (illustrative):

{
"nodes": [
{ "id": "http_0", "type": "http" },
{
"id": "code_0",
"type": "code",
"data": {
"inputsValues": {
"input": { "type": "ref", "content": ["http_0", "body"] }
},
"script": { "language": "javascript", "content": "async function main(params){ return { result: params.input }; }" }
}
}
],
"edges": [{ "sourceNodeID": "http_0", "targetNodeID": "code_0" }]
}