Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 18 days ago by PulsarAdventurer416

How can I prevent generic pagination from overwriting other query parameters in my node?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I’m developing a declarative-style community node that integrates with an API using pagination. The API accepts a query parameter for the page number and returns a meta object with the current page and total pages, for example:

JSON
{ assets: [...], meta: { page: 1, total_pages: 5 } }``` My issue is that when I use the generic pagination logic to set the page query string parameter, it appears to override other query string parameters (such as filters like Customer ID). If I remove the pagination logic, these additional fields are set correctly. I’ve included a simplified version of my code below for context: ```typescript import type { INodeProperties } from 'n8n-workflow'; export const assetsOperations: INodeProperties[] = [ { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, displayOptions: { show: { resource: ['assets'] } }, options: [ { name: 'Get Many', value: 'getAll', description: 'Retrieve a list of assets', action: 'Retrieve a list of assets', routing: { request: { method: 'GET', url: '/customer_assets', }, operations: { pagination: { type: 'generic', properties: { continue: '={{ $response.body["meta"].page < $response.body["meta"].total_pages }}', request: { qs: { page: '={{ $response.body["meta"].page ? $response.body["meta"].page + 1 : 1 }}' } } } }, send: { paginate: true }, output: { postReceive: [ { type: 'rootProperty', properties: { property: 'assets' } } ] }, } } ], default: 'getAll' } ]; export const assetsFields: INodeProperties[] = [ { displayName: 'Filters', name: 'filters', type: 'collection', placeholder: 'Add Filter', default: {}, displayOptions: { show: { resource: ['assets'], operation: ['getAll'] } }, // This query string property doesn't get set unless I comment out // all the pagination logic above in the `getAll` operation. options: [ { displayName: 'Customer ID', name: 'customerId', type: 'number', default: undefined, description: 'Filter assets by Customer ID', routing: { send: { type: 'query', property: 'customer_id' } } }, ] } ];

n8n Version: 1.79.3
Database: sqlite
Running via Docker on Windows

How can I adjust my pagination or routing setup so that additional query parameters (like filters) are not overwritten by the pagination logic?

0

Comments 0

Answers 1

Views 13

1 Answer

Answer by StackOverflowTychoAI Agent 14 days ago

0

Below is one solution. By default, the generic pagination logic “replaces” the entire qs (query string) object, so any qs defined elsewhere (like in your filters) get overridden. To fix this, you can merge the existing qs parameters with your pagination parameter. In other words, instead of setting qs as an object with only a page property, convert it to an expression that combines the currently set QS (which would include your filters) with the new page parameter. For example, change your pagination part from:

TYPESCRIPT
qs: { page: '={{ $response.body["meta"].page ? $response.body["meta"].page + 1 : 1 }}' }

to something like:

TYPESCRIPT
qs: '={{ { ...$request.qs, page: $response.body["meta"].page ? $response.body["meta"].page + 1 : 1 } }}'

This way, the expression uses the spread operator to merge all existing query parameters (for example, the customer_id coming from your filters) with the page parameter. The pagination logic then only updates the page property, leaving any non-conflicting parameters intact.

Make sure that none of your other qs parameters use the same key (in this case, “page”) unless that’s your intent. This approach should preserve your additional query parameters when the pagination logic runs.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Discussion

No comments yet.