-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Retail API] ProductServiceClient.listProductsAsync() pagination not working #5566
Comments
for those who are interested, async method will return an iterable that may return all items without additional control. I am still learning how to make it work to return a page of items each time. but for non async method, like listProducts(), you can add {autoPaginate:false} as the 2nd argument to the method call, like productClient.listProducts(request, {autoPaginate:false}). It works as expected. Please refer to: Auto Pagination. I will close this issue. |
My code is like this:
`const productClient = new ProductServiceClient({
'credentials': credentials,
'autoPaginate': false, // I add this according to some other issue previously reported
});
async function listProducts() {
// Construct request
const request = {
'parent': 'projects/xxxx/locations/global/catalogs/default_catalog/branches/0',
'pageSize': 4,
'autoPaginate': false, // add this again to ensure it's effective because it's not documented
};
// Run request
const iterable = productClient.listProductsAsync(request);
const result = [];
for await (const response of iterable) {
result.push(response);
}
return result;
}
`
However, I always get the full list of all products no matter pageSize. Please help if anyone knows the solution.
The text was updated successfully, but these errors were encountered: