mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ woocommerce node
This commit is contained in:
@@ -47,6 +47,25 @@ export async function woocommerceApiRequest(this: IHookFunctions | IExecuteFunct
|
||||
}
|
||||
}
|
||||
|
||||
export async function woocommerceApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
let uri: string | undefined;
|
||||
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('>','');
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
} while (
|
||||
responseData.headers['link'] !== undefined &&
|
||||
responseData.headers['link'].includes('rel="next"')
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a secret from the credentials
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user