Added new option to readme, and clarified the option name

This commit is contained in:
Justin 2018-06-01 20:41:18 -04:00
parent 178ef7568e
commit 3ffcbd66ff
2 changed files with 25 additions and 2 deletions

View File

@ -343,6 +343,29 @@ 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:
```javascript
...
let { data, pagination } = await api.Projects.all({ perPage:40, maxPages:2, showPagination: true });
...
```
This will result in a response in this format:
```javascript
data: [
...
],
pagination: {
next: 4,
current: 2,
perPage: 3,
previous: 1,
total: 3,
}
```
## Migrating from node-gitlab/node-gitlab
With the success of this library thanks to the community, this has become the main npm package to interact with the Gitlab API. As such, there will be a little bit of growing pains for those upgrading from the original node-gitlab v1.8 to our newest 3.0.0 release, far too many to list here. I hope the library is written clearly enough to ease this transition, but if there is anything that you're having trouble with please feel free to create an issue! If not myself, someone will definitely have the answer to help get you all setup up as quickly as possible.

View File

@ -49,7 +49,7 @@ function getStream(service, endpoint, options = {}) {
}
async function getPaginated(service, endpoint, options = {}) {
const { pagination, maxPages, ...queryOptions } = options;
const { showPagination, maxPages, ...queryOptions } = options;
const requestOptions = defaultRequest(service, endpoint, {
headers: service.headers,
qs: queryOptions,
@ -70,7 +70,7 @@ async function getPaginated(service, endpoint, options = {}) {
const data = [...response.body, ...more];
if (!queryOptions.page && pagination) {
if (!queryOptions.page && showPagination) {
return {
data,
pagination: {