Class: Pages

(abstract) Pages(connection, endpoint, key, cls, paramsopt, primaryKey)

A class to handle pagination of resources.

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
Source:

Methods

_cache(objects) → {Array.<object>}

Caches the plain objects if needed.

Parameters:
Name Type Description
objects Array.<object>
Source:
Returns:
Type
Array.<object>

(protected) _createObject(obj) → {object}

Creates a facade for the object, if needed.

Parameters:
Name Type Description
obj object
Source:
Returns:
Type
object

(protected) _ensureArray(x) → {Array}

Ensures a variable is an array.

Parameters:
Name Type Description
x *
Source:
Returns:
Type
Array

Get the URL of the next page from a response.

Parameters:
Name Type Description
response AxiosResponse
Source:
Returns:
Type
string | null

hasNextPage() → {boolean}

Returns true if there are more pages to fetch.

Source:
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.

Source:
Throws:
Error
Returns:
Type
Array.<object>