Merging multiple items into one

Hey!

I cannot for the life of me figure out how to merge these three items into on bigger JSON item. I have tried scouring this forum, using AI and other forums, but I cannot figure it out.

I have a HTTP request that gives me a max result of 100, if there are more it will give me a next_page href that i check with the IF node. I first tried the merge node by parsing the first http result + every other http result that requests the next 100 items with the given href.

I have also tried Aggregate node, but no matter what I do, I cannot merge these 3 items into 1 bigger, I do not understand what I am doing wrong

Welcome to the community! :grinning:

something like this should work if you want to get only one item at the end

1 Like

Thanku! :smiley:

I really did wish that would work, although now I do only get 2 items, so it’s an improvement I guess… also tried adding a third input being the false IF test

could you share the workflow maybe with mock data?
so i can test it, because that should work

Are you saying you have 3 pages worth of arrays you want to append into one list? If so then I would recommend using a Loop node and then Merge with append. Inside the loop will be your if to check if you should continue paging or exist out returning the result.

For example here Im scraping a website for products. I page through all pages and collect the results. In this example i did not use a merge but a code block in the end to merge all execution results into one

EDIT: I realize my example does not use the loop node, but another looping mechanism

{
“nodes”: [
{
“parameters”: {
“numberInputs”: 3
},
“type”: “n8n-nodes-base.merge”,
“typeVersion”: 3.1,
“position”: [
700,
-20
],
“id”: “1a7545f8-2268-4208-b084-ddf6824675fc”,
“name”: “Merge”
},
{
“parameters”: {
“fieldsToAggregate”: {
“fieldToAggregate”: [
{}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.aggregate”,
“typeVersion”: 1,
“position”: [
900,
-20
],
“id”: “6be65cb5-a28c-4db8-ba54-5df38cdd0f5c”,
“name”: “Aggregate”
}
],
“connections”: {
“Merge”: {
“main”: [
[
{
“node”: “Aggregate”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “00fde464eef29fc658368cea7ac0dfbc3c4bc0aafe7f6d467caf17d136120382”
}
}

like this?

I have tried following what you said, but I am not able to replicate it in my instance. Can I share the workflow with you?

try something like that if u want it in an array to process it with a code node

ignore my limit nodes its just for limiting the test api results bc the output is too big for the forum

but with the data you get, you might have to adjust it

or with a code node

1 Like

Starting to think there is no way to do it in my workflow, which is very disappointing as this is something one could easily code, it does make me question how good n8n really is.

I can not think of any other ways to do this process, I have tried multiple ways.