mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(n8n Node): fix resource locator not returning all items (#4248)
This commit is contained in:
committed by
GitHub
parent
971c2c0aed
commit
ed4dcbb5dd
@@ -24,7 +24,8 @@ export async function apiRequest(
|
||||
endpoint: string,
|
||||
body: object,
|
||||
query?: IDataObject,
|
||||
): Promise<unknown> {
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
query = query || {};
|
||||
|
||||
type N8nApiCredentials = {
|
||||
@@ -39,7 +40,7 @@ export async function apiRequest(
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
uri: `${baseUrl}/${endpoint}`,
|
||||
uri: `${baseUrl.replace(new RegExp('/$'), '')}/${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
@@ -53,6 +54,30 @@ export async function apiRequest(
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiRequestAllItems(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
body: object,
|
||||
query?: IDataObject,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
query = query || {};
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let nextCursor: string | undefined = undefined;
|
||||
let responseData;
|
||||
|
||||
do {
|
||||
query.cursor = nextCursor;
|
||||
query.limit = 100;
|
||||
responseData = await apiRequest.call(this, method, endpoint, body, query);
|
||||
returnData.push.apply(returnData, responseData.data);
|
||||
nextCursor = responseData.nextCursor as string | undefined;
|
||||
} while (nextCursor);
|
||||
return returnData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cursor-based paginator to use with n8n 'getAll' type endpoints.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user