Hey @ArielGonzales Welcome to the n8n community!
You’re very close! The missing piece is configuring the HTTP Request node’s pagination to follow odata.nextLink, and then adjusting your Code node to process the complete paginated output.
1. Set Up Pagination on the HTTP Request Node
Your SAP OData response includes:
{
"value": [ /* 20 items */ ],
"odata.nextLink": "Items?$filter=Properties34%20eq%20%27tYES%27&$skip=20"
}
How to configure:
- In your HTTP Request node, go to Options > Pagination.
- Set Pagination Mode to Response Contains Next URL.
- In Next URL (expression), insert:
{{
$response.body['odata.nextLink']
? 'https://10.80.13.139:50000/b1s/v1/' + $response.body['odata.nextLink']
: null
}}
This instructs n8n to keep following the URLs provided in odata.nextLink until it’s null.
- Set Complete Pagination When to:
{{ !$response.body['odata.nextLink'] }}
This tells n8n when to stop paginating (when odata.nextLink is missing or null).
- You can leave Max Requests high or empty to fetch all pages.
Result:
n8n will automatically fetch all pages, concatenating all items into a single output.
2. Adjust Your Code Node for the Combined Output
Previously, your code assumed a single response with a value array:
const data = $input.first().json.value;
Now, with pagination, each item in $input represents one item from the combined list, not a page.
Update your code to process all input items:
const items = $input.all();
return items.map(item => {
const raw = item.json;
const rawStock = Number(raw.QuantityOnStock || 0);
const stock = rawStock > 199 ? 199 : rawStock;
let status;
if (raw.Valid === 'tNO') {
status = 'discontinued';
} else if (raw.Frozen === 'tYES') {
status = 'out-of-stock';
} else if (rawStock > 0) {
status = 'in-stock';
} else {
status = 'out-of-stock';
}
return {
json: {
sku: raw.ItemCode,
upc: '',
ean: raw.BarCode || '',
quantity_available: Math.trunc(stock),
cost: Number(Number(raw.ItemPrices[11].Price || 0).toFixed(2)),
status,
warehouse_code_1: 'ARTERO',
warehouse_quantity_1: Math.trunc(stock),
},
};
});
This way, your code processes all items seamlessly.
3. No Need for Manual Looping
Since the HTTP node handles pagination internally, you don’t need an extra Loop node or manual iteration. It will output all items combined, ready for the next steps.
If you follow these steps, your workflow should correctly handle all paginated data! Let me know if this helps, i have faced the same issue where the error was in my javascript