-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
Missing pagination information in response #94
Comments
The library should return all the projects, as the pagination is handled in the background. We changed it in the past to not just return 30 results since it was misleading. 30 != all lol. If it is only returning 30, then something is probably broken :( I can look into this? |
So i just tested this, it still returns all the results which is good. Would you like more information when using the paging options? |
Hey, thanks for the reponse! I am using the api like this
I get a maximum of 20 per page by default(I guess limited because I am using So it would be great if you could add another field in the response along with projects, lets say Thanks again! |
Very doable. I'll add in an option to also retrieve the pagination information |
In this example,
page is variable right? You can also get more results if you supply the perPage option which will give you more results per page. |
Yep. |
So ive been thinking about the cleanest way to do this but havent come up with the best solution :s. pretty much just an expanded response: {
data: []
pagination: {
}
} Thoughts? |
I think that should work! So I can access the pagination data by doing something like this? client.Projects.all({page:page,owned:true}).then((projects, pagination) => {
var totalPages = pagination['X-Total'] It doesnt't break anyones code either. So I think this is a pretty good way to add this. Thanks :) |
Should I abstract out the pagination keys too? Like:
OR
|
Yep, that would make it really clean! pagination: {
nextPage: 4,
currentPage: 2,
itemsPerPage: 3,
previousPage: 1,
totalPages: 3
} Maybe too verbose :P But anything works, really. Thanks :D |
Just added the functionality to the pagination branch, using this syntax:
|
just published! Tell me if it works for you |
Awesome! I'll test and let you know soon. Thanks a ton |
I was not able to get this working. This is what I tried client.Projects.all({page:page,owned:true,pagination:true}).then((projects,pagination) => {
console.log(pagination) But the Thanks |
Why projects.paginatiom ? |
The return would be ({ data, pagination}) => { console.log(pagination)} |
And the option is showPagination : true. Changed it for clarity |
Thanks, missed the If the I think this is because of src/infrastructure/RequestHelper.js if (!queryOptions.page && showPagination) {
return {
data,
pagination: {
.... |
Perks of coding while tired smh. I'll fix it tonight sorry |
No problem! And thanks a lot :) |
Fixing it now, and adding tests so i dont make the same mistake in the future :P |
Will release today! Added tests as well. |
Oh and also note the properties have changed a bit. Check the readme :) |
Awesome, will try once it's released. Thank you 👍 |
When I use the
Projects.all()
call to list projects it by default lists up to 30 projects. But if there are more thanperPage
number of projects, there is no way to know based on the data returned by the function. This makes it difficult to implement pagination in UI.The Gitlab API returns this information as part of the headers
Example
Am I missing something? What is the best way to get the pagination information along with the response?
Thank you :)
The text was updated successfully, but these errors were encountered: