构建工作流

Get number of items returned by last 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
	}
]

官方原文和授权

本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。

来源、授权与修改

本站保留许可证、固定提交号、社区作者和修改说明,不代表 n8n 对本站背书。

查看许可证查看来源和修改说明