mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(WooCommerce Node): Fix pagination issue with "Get All" operation (#2529)
This commit is contained in:
parent
358a683f38
commit
c2a5e0d1b6
|
@ -53,7 +53,6 @@ export async function woocommerceApiRequest(this: IHookFunctions | IExecuteFunct
|
|||
uri: uri || `${credentials.url}/wp-json/wc/v3${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (credentials.includeCredentialsInQuery === true) {
|
||||
delete options.auth;
|
||||
Object.assign(qs, { consumer_key: credentials.consumerKey, consumer_secret: credentials.consumerSecret });
|
||||
|
@ -79,7 +78,11 @@ export async function woocommerceApiRequestAllItems(this: IExecuteFunctions | IL
|
|||
query.per_page = 100;
|
||||
do {
|
||||
responseData = await woocommerceApiRequest.call(this, method, endpoint, body, query, uri, { resolveWithFullResponse: true });
|
||||
uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', '');
|
||||
const links = responseData.headers.link.split(',');
|
||||
const nextLink = links.find((link: string) => link.indexOf('rel="next"') !== -1);
|
||||
if (nextLink) {
|
||||
uri = nextLink.split(';')[0].replace(/<(.*)>/, '$1');
|
||||
}
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
} while (
|
||||
responseData.headers['link'] !== undefined &&
|
||||
|
@ -156,7 +159,7 @@ export function setFields(fieldsToSet: IDataObject, body: IDataObject) {
|
|||
} else {
|
||||
body[snakeCase(fields.toString())] = fieldsToSet[fields];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue