JsonServerResponseStrategy
ArchivedThese are the docs for ng-qubee 3.8. Read the 4.0 docs for @qubeejs/angular.
Defined in: src/lib/strategies/json-server-response.strategy.ts:42
Response strategy for the json-server driver
Parses json-server v1 paginated responses:
{ "first": 1, "prev": null, "next": 2, "last": 5, "pages": 5, "items": 48, "data": [...]}Uniquely among the drivers, first / prev / next / last are
page numbers, not URLs — so the navigation-URL slots on
PaginatedCollection stay undefined and the strategy instead uses
the numbers to derive position:
currentPageisprev + 1(prev === null→ page 1).perPageis the item count of the current page whenevernextis set (a page with a successor is necessarily full); on the last page of a multi-page set it is not introspectable and staysundefined.lastPagecomes straight frompages;from/toderive fromcurrentPage×perPageon full pages, or count back from the total on the last page (from = total - items + 1,to = total).
The data / items / pages key paths are configurable through
JsonServerResponseOptions; the prev / next keys are fixed by the
json-server envelope and live as private statics.
https://github.com/typicode/json-server
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new JsonServerResponseStrategy():
JsonServerResponseStrategy
Returns
Section titled “Returns”JsonServerResponseStrategy
Methods
Section titled “Methods”paginate()
Section titled “paginate()”paginate<
T>(response,options):PaginatedCollection<T>
Defined in: src/lib/strategies/json-server-response.strategy.ts:61
Parse a json-server pagination response into a PaginatedCollection
Type Parameters
Section titled “Type Parameters”T extends IPaginatedObject
Parameters
Section titled “Parameters”response
Section titled “response”Record<string, any>
The raw API response body
options
Section titled “options”The response key name configuration
Returns
Section titled “Returns”A typed PaginatedCollection instance