fix(shopify): prevent infinite loop during all items request

This commit is contained in:
kodaho 2025-01-28 19:44:38 +01:00
parent ac84ea1445
commit 8c11edd7e0
No known key found for this signature in database
GPG key ID: ACFA0533C5A30ED5

View file

@ -113,8 +113,12 @@ export async function shopifyApiRequestAllItems(
responseData = await shopifyApiRequest.call(this, method, resource, body, query, uri, { responseData = await shopifyApiRequest.call(this, method, resource, body, query, uri, {
resolveWithFullResponse: true, resolveWithFullResponse: true,
}); });
if (responseData.headers.link) { if (responseData.headers.link?.includes('rel="next"')) {
uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); uri = responseData.headers.link
.split(';')
.filter((s: string) => s.includes('rel="next"'))[0]
.replace('<', '')
.replace('>', '');
} }
returnData.push.apply(returnData, responseData.body[propertyName] as IDataObject[]); returnData.push.apply(returnData, responseData.body[propertyName] as IDataObject[]);
} while (responseData.headers.link?.includes('rel="next"')); } while (responseData.headers.link?.includes('rel="next"'));