mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
Fix pagination to enforce limit
This commit is contained in:
parent
52dd2502fd
commit
72548d9523
|
@ -83,8 +83,6 @@ export async function redditApiRequestAllItems(
|
|||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
qs.limit = 100;
|
||||
|
||||
do {
|
||||
responseData = await redditApiRequest.call(this, method, endpoint, qs);
|
||||
if (!Array.isArray(responseData)) {
|
||||
|
@ -99,6 +97,10 @@ export async function redditApiRequestAllItems(
|
|||
responseData.data.children.forEach((child: any) => returnData.push(child.data)); // tslint:disable-line:no-any
|
||||
}
|
||||
|
||||
if (qs.limit && responseData.data.children.length >= qs.limit) {
|
||||
return returnData;
|
||||
}
|
||||
|
||||
} while (responseData.data && responseData.data.after);
|
||||
|
||||
return returnData;
|
||||
|
|
|
@ -402,13 +402,11 @@ export class Reddit implements INodeType {
|
|||
const details = this.getNodeParameter('details', i) as string;
|
||||
const endpoint = `user/${username}/${details}.json`;
|
||||
|
||||
responseData = ['about', 'gilded'].includes(details)
|
||||
responseData = details === 'about'
|
||||
? await redditApiRequest.call(this, 'GET', endpoint, {})
|
||||
: await handleListing.call(this, i, endpoint);
|
||||
|
||||
if (details === 'gilded') {
|
||||
responseData = responseData.data.children;
|
||||
} else if (details === 'about') {
|
||||
if (details === 'about') {
|
||||
responseData = responseData.data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue