Constructor
(abstract) new Pages(connection, endpoint, key, cls, paramsopt, primaryKey)
Creates an instance of Pages.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
connection |
Connection | |||
endpoint |
string | |||
key |
string | |||
cls |
Constructor | |||
params |
object |
<optional> |
{} | |
primaryKey |
string | id |
Methods
_cache(objects) → {Array.<object>}
Caches the plain objects if needed.
Parameters:
Name | Type | Description |
---|---|---|
objects |
Array.<object> |
Returns:
- Type
- Array.<object>
(protected) _createObject(obj) → {object}
Creates a facade for the object, if needed.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object |
Returns:
- Type
- object
(protected) _ensureArray(x) → {Array}
Ensures a variable is an array.
Parameters:
Name | Type | Description |
---|---|---|
x |
* |
Returns:
- Type
- Array
(protected) _getNextLink(response) → {string|null}
Get the URL of the next page from a response.
Parameters:
Name | Type | Description |
---|---|---|
response |
AxiosResponse |
Returns:
- Type
- string | null
hasNextPage() → {boolean}
Returns true if there are more pages to fetch.
Returns:
- Type
- boolean
(async) nextPage(oldObjects, toArrayopt) → {Array.<object>}
Returns the next page of resources.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
oldObjects |
Array.<object> | Existing objects to update, if any. |
||
toArray |
boolean |
<optional> |
true | Whether to return the objects as a simplified array or as an object with all information. |
Throws:
Error
Returns:
- Type
- Array.<object>