v2.17.0 breaks fetchNextPage?
mbritton-ms opened this issue · comments
Bug details
Describe the bug
I have been using the https://sdks.shopifycdn.com/js-buy-sdk/v2/latest/index.umd.min.js version of the Shopify JS Buy SDK. Before the update to v2.17.0, I could fetch all the products in a store by using FetchAll and then FetchNextPage for pagination.
After the update, I get the following:
index.umd.min.js:26 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'products')
at index.umd.min.js:26:142336
at Array.reduce (<anonymous>)
at index.umd.min.js:26:142307
To Reproduce
The client is intialised as per normal (obscuring for privacy):
const client = ShopifyBuy.buildClient({
domain: 'XXXXXX.myshopify.com',
storefrontAccessToken: 'XXXXXXXXXXXXXXX'
});
The code to fetch the products:
var allProducts = [];
console.log(("getAllProducts()");
return new Promise((resolve, reject) =>
{
client.product.fetchAll(250).then((products) => {
products.forEach(el => {
allProducts.push(el);
});
client.fetchNextPage(products).then((res) => {
res.model.forEach(el => {
allProducts.push(el);
});
console.log("Returning All Products:");
console.log((allProducts);
resolve(allProducts);
});
});
})
}
As I have said, if I downgrade to version 2.16.1 this command works again, and there is nothing in the change log about fetchNextPage being altered.
Output from my console - 2.16.1 on the left, 2.17.0 on the right.
Expected behavior
When this code is run, I expect it to get all the products currently in the store (368 at this time) and return them to me in a created array - as it does in version 2.16.1.
Environment (please complete the following information):
-OS: Windows 10
-Browser: Chrome 106.0.5249.119
-SDK Version: 2.17.0 (error), 2.16.1 (works)
-Languages: HTML5/Javascript
Additional context
Thank you for your time, I hope this can be identified and fixed.
Bug Report Checklist
- I have read and agree to the CODE_OF_CONDUCT.md
- I have read the CONTRIBUTING.md guidelines.
- I have provided a detailed description of the bug, including code samples, and/or network data.
- I have provided information about my development environment, including SDK version.
Thanks for reporting this issue - it's fixed in the latest v2.17.1
.