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 6a98491 commit fecbc17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,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 @@ -337,11 +337,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 @@ -48,7 +48,7 @@ class RequestHelper {
return [...body, ...more];
}

return showPagination ? { data: body, pagination } : body;
return (query.page || maxPages) && showPagination ? { data: body, pagination } : body;
}

static async stream(service, endpoint: string, options: BaseRequestOptions = ({} = {})) {
Expand Down

0 comments on commit fecbc17

Please sign in to comment.