Code node common issues
Here are some common errors and issues with the Code node and steps to resolve or troubleshoot them.
A 'json' property isn't an object
This error occurs when the Code node returns data where the json
key isn't pointing to an object.
This may happen if you set json
to a different data structure, like an array:
[
{
"json": [
// Setting `json` to an array like this will produce an error
]
}
]
To resolve this, ensure that the json
key references an object in your return data:
[
{
"json": {
// Setting `json` to an object as expected
}
}
]
Using global variables
Sometimes you may wish to set and retrieve simple global data related to a workflow across and within executions. For example, you may wish to include the date of the previous report when compiling a report with a list of project updates.
To set, update, and retrieve data directly to a workflow, use the static data functions within your code. You can manage data either globally or tied to specific nodes.
If you're interested in using variables to avoid processing the same data items more than once, consider using the Remove Duplicates node instead. The Remove Duplicates node can save information across executions to avoid processing the same items multiple times.