diff --git a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts index ced6ff39f9..0ee6221824 100644 --- a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts @@ -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; diff --git a/packages/nodes-base/nodes/Reddit/Reddit.node.ts b/packages/nodes-base/nodes/Reddit/Reddit.node.ts index a3575afea4..c7ece3903c 100644 --- a/packages/nodes-base/nodes/Reddit/Reddit.node.ts +++ b/packages/nodes-base/nodes/Reddit/Reddit.node.ts @@ -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; } }