I’m trying to understand how split in batches node works, this is a basic example that I’m working on
So I’m tying to fetch 1 by 1 the cities that are return by the function node
I’m trying to understand how split in batches node works, this is a basic example that I’m working on
So I’m tying to fetch 1 by 1 the cities that are return by the function node
Hey, @Juan_Gabriel_Fraire welcome to the community, I think you can do what you want to do without using the split baches node. Check the example below. Just add your apiKey under appid and then execute the workflow.
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
340,
350
]
},
{
"parameters": {
"functionCode": "return [ { json: { city: 'orlando' } }, { json: { city: 'miami' } } ]\n"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
590,
350
]
},
{
"parameters": {
"url": "http://api.openweathermap.org/data/2.5/weather",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "appid",
"value": "01051d1267e38c490bcc447d3a18f738"
},
{
"name": "q",
"value": "= {{$node[\"Function\"].data[\"city\"]}}"
}
]
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
890,
350
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Function": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Thanks!, But my question was more related to understand the tool better, and from the conclusion maybe improve the documentation about how to do use it. I mean maybe we should point people to use more function nodes instead, that’s also a valid answer.
I see @Juan_Gabriel_Fraire , execute this example and you will catch the execution flow and hopefully how to use the node.
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
340,
340
]
},
{
"parameters": {
"functionCode": "return [ { json: { city: 'orlando' } }, { json: { city: 'miami' } } ]\n"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
590,
340
]
},
{
"parameters": {
"batchSize": 1
},
"name": "SplitInBatches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
840,
340
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{$node[\"SplitInBatches\"].context[\"noItemsLeft\"]}}"
}
]
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1190,
70
]
},
{
"parameters": {},
"name": "Function1",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1410,
330
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Function": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatches": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
],
[
{
"node": "Function1",
"type": "main",
"index": 0
}
]
]
}
}
}
Thanks!! I will give a try and maybe document it.
Hey @Juan_Gabriel_Fraire!
It’s been long, and we have made a lot of improvements to n8n
I was wondering if you needed more help here. If not, I will close this topic