Hey everyone, thanks for your responses!
@tony: yeah, I figured I could do something like that but it just seems to be unnecessarily complicated. But thanks for posting an example schema, will certainly help if I have to go down that route…
@RicardoE105: Let’s say we have a similar API like jan and slavielle were discussing above that responds with links to the next page of entries. Jan suggested the looping between HTTP Request and If, which certainly works but I couldn’t figure out how to merge the resulting six responses into one. I’ve prepared an example. If you have any idea I would love to hear it!
Best, Simon
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"url": "={{$json[\"links\"][\"next\"]}}",
"options": {},
"queryParametersUi": {
"parameter": []
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
860,
300
]
},
{
"parameters": {
"conditions": {
"boolean": [],
"string": [
{
"value1": "={{Object.keys($node[\"HTTP Request\"].json[\"links\"]).join(', ')}}",
"operation": "contains",
"value2": "next"
}
]
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
860,
530
],
"alwaysOutputData": false
},
{
"parameters": {
"values": {
"string": [
{
"name": "links.next",
"value": "https://discuss.flarum.org/api/discussions?filter[q]=+tag:blog&fields[discussions]=title&page[size]=10"
}
]
},
"options": {}
},
"name": "Set Initial URL",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
560,
300
]
},
{
"parameters": {},
"name": "All pages fetched",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
1220,
550
]
},
{
"parameters": {
"functionCode": "const response = [];\nfor (const item of items) {\n for (const results of item.json.data) {\n response.push({\n json: {\n title: results.attributes.title\n }\n })\n }\n}\n\nreturn response;"
},
"name": "merge results ??",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1220,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set Initial URL",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
},
{
"node": "merge results ??",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
],
[
{
"node": "All pages fetched",
"type": "main",
"index": 0
}
]
]
},
"Set Initial URL": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}