Skip to content

Commit

Permalink
fix: Update pagination docs and conditions #238
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Nov 26, 2018
1 parent cce5f35 commit 266de00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ api.Projects.create(projectId, {

For any .all() function on a resource, it will return all the items from Gitlab. This can be troublesome if there are many items, as the request it self can take a while to be fulfilled. As such, a maxPages option can be passed to limit the scope of the all function.


```javascript
import Gitlab from 'gitlab';

Expand All @@ -337,7 +336,7 @@ const api = new Gitlab({
token: 'abcdefghij123456' // Can be created in your profile.
});

let projects = await api.Projects.all({maxPages:2});
let projects = await api.Projects.all({ maxPages:2 });

```

Expand All @@ -351,11 +350,12 @@ const api = new Gitlab({
token: 'abcdefghij123456' // Can be created in your profile.
});

let projects = await api.Projects.all({maxPages:2, perPage:40});
let projects = await api.Projects.all({ maxPages:2, perPage:40 });

```

Additionally, if you would like to get back the pagination information, to know how many total pages there are for example, pass the pagination option:
Additionally, if you would like to get back the pagination information, to know how many total pages there are for example, pass the pagination option `showPagination` in addition to either the
`maxPages` or `page` properties.

```javascript
...
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/RequestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function getPaginated(
data = response.body;
}

if (queryOptions.page && showPagination) {
if ((queryOptions.page || maxPages) && showPagination) {
return {
data,
pagination: {
Expand Down

0 comments on commit 266de00

Please sign in to comment.