-
Notifications
You must be signed in to change notification settings - Fork 62
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
Prismic Client ignores and overwrites 'page' query param for getAll methods #369
Comments
Hi there, thank you so much for the report! Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:
If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process. If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io - The Prismic Open-Source Team |
I opened a PR for this issue. |
Hi @malee31, thank you so much for your research and effort in submitting a PR to From the above context you shared, it looks like you're trying to implement document pagination using Refactoring the above snippet, something like this should achieve the desired result: - const pageOne = await client.getAllByType(documentType, {
+ const { results: pageOne } = await client.getByType(documentType, {
page: 1,
- limit: 2,
pageSize: 2,
orderings: {
field: "document.first_publication_date",
direction: "desc",
},
});
- const pageTwo = await client.getAllByType(documentType, {
+ const { results: pageTwo } = await client.getByType(documentType, {
page: 2,
- limit: 2,
pageSize: 2,
orderings: {
field: "document.first_publication_date",
direction: "desc",
},
}); Maybe I got the context wrong in what you're trying to achieve so happy to have another look at it :) Best, Lucie |
Hi @lihbr , Thank you, that does resolve my pagination use case. After thinking about it more, while I no longer need this change, I think a starting page might still be worth adding to the Since the team designed If not, it would be nice to put a warning message with a redirect/link for anyone else that passes in the |
Outside of that, could I suggest that the documentation be improved to reflect the
I think it would be helpful to have a dedicated page for how to paginate with In case it helps, my initial confusion came from unclear documentation on the Prismic Client Technical Reference. The page does not specify the type/properties of Since the |
Versions
Reproduction
Create 4 documents of the same type, configure the following snippet, and run.
Steps to reproduce
index.js
npm init
npm install @prismicio/client
repo
anddocumentType
node index.js
What is expected?
From the documentation for query method params, we are able to pass the
?page=#
to the REST API to paginate our results withpageSize
.So passing in
page: 2
should return the second page of results.What is actually happening?
Regardless of which page is being queried for through the client
getAll*
functions, results start from the very first page.The issue comes from src/Client.ts:622 where the starting page is always
undefined
which defaults to1
.This can be fixed by changing the default value used by the client to start from
actualParams.page
when provided rather thanundefined
.The text was updated successfully, but these errors were encountered: