mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
🐛 Fix pagination issue with Slack node (#2328)
* ⚡ Fix pagination in Slack-Node Previously, if you had more than 1k channels, only the first 1k would be loaded. Now with pagination, the limit is ~40k (due to rate limiting, which this doesn't handle well) * 🐛 Fix issue with pagination Continues with #2308 Co-authored-by: Fahrzin Hemmati <fahhem@users.noreply.github.com>
This commit is contained in:
parent
0b1b4baaab
commit
3af223cd8e
|
@ -71,15 +71,21 @@ export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOpt
|
|||
const returnData: IDataObject[] = [];
|
||||
let responseData;
|
||||
query.page = 1;
|
||||
query.count = 100;
|
||||
//if the endpoint uses legacy pagination use count
|
||||
//https://api.slack.com/docs/pagination#classic
|
||||
if (endpoint.includes('files.list')) {
|
||||
query.count = 100;
|
||||
} else {
|
||||
query.limit = 5;
|
||||
}
|
||||
do {
|
||||
responseData = await slackApiRequest.call(this, method, endpoint, body, query);
|
||||
query.cursor = encodeURIComponent(_.get(responseData, 'response_metadata.next_cursor'));
|
||||
query.cursor = _.get(responseData, 'response_metadata.next_cursor');
|
||||
query.page++;
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
(responseData.response_metadata !== undefined &&
|
||||
responseData.response_metadata.mext_cursor !== undefined &&
|
||||
responseData.response_metadata.next_cursor !== undefined &&
|
||||
responseData.response_metadata.next_cursor !== '' &&
|
||||
responseData.response_metadata.next_cursor !== null) ||
|
||||
(responseData.paging !== undefined &&
|
||||
|
|
Loading…
Reference in a new issue