|
Download docs/code/cookbook/code-node/number-items-last-node.md from Jeice/n8n-docs-v2: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/datasets/Jeice/n8n-docs-v2/resolve/main/docs/code/cookbook/code-node/number-items-last-node.md
- Command line
-
hf download hf://datasets/Jeice/n8n-docs-v2/docs/code/cookbook/code-node/number-items-last-node.md
-
curl -L -o number-items-last-node.md https://huggingface.co/datasets/Jeice/n8n-docs-v2/resolve/main/docs/code/cookbook/code-node/number-items-last-node.md
798 Bytes
metadata
contentType: howto
Get number of items returned by the previous node
To get the number of items returned by the previous node:
=== "JavaScript"
```js
if (Object.keys(items[0].json).length === 0) {
return [
{
json: {
results: 0,
}
}
]
}
return [
{
json: {
results: items.length,
}
}
];
```
The output will be similar to the following.
```json
[
{
"results": 8
}
]
```
=== "Python"
python if len(items[0].json) == 0: return [ { "json": { "results": 0, } } ] else: return [ { "json": { "results": items.length, } } ]
The output will be similar to the following.
```json
[
{
"results": 8
}
]
```