DrfResponseStrategy
ArchivedThese are the docs for ng-qubee 3.8. Read the 4.0 docs for @qubeejs/angular.
Defined in: src/lib/strategies/drf-response.strategy.ts:43
Response strategy for the Django REST Framework (DRF) driver
Parses DRF PageNumberPagination responses:
{ "count": 100, "next": "http://api.example.com/items/?page=3", "previous": "http://api.example.com/items/?page=1", "results": [...]}DRF emits no current_page field in the body, so this strategy
derives the current page (and the page size) by inspecting the
next / previous URLs:
previous === null→ current page is 1.previousset but has no?page=Nparam → DRF omitspage=1from URLs when the previous page is the first, so we infer 2.previoushas?page=N→ current page is N + 1.
Similarly, perPage is parsed from any ?page_size=N query param on
next or previous, and lastPage is computed as
ceil(count / perPage). When perPage cannot be discovered (e.g. on a
single-page response that emits both URLs as null), perPage and
lastPage are left undefined.
Key paths are resolved through DrfResponseOptions, which defaults
data → 'results', total → 'count', nextPageUrl → 'next',
prevPageUrl → 'previous'. The current-page / per-page / last-page
paths default to empty strings — the strategy ignores options for
those slots and uses URL inspection instead.
https://www.django-rest-framework.org/api-guide/pagination/#pagenumberpagination
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DrfResponseStrategy():
DrfResponseStrategy
Returns
Section titled “Returns”DrfResponseStrategy
Methods
Section titled “Methods”paginate()
Section titled “paginate()”paginate<
T>(response,options):PaginatedCollection<T>
Defined in: src/lib/strategies/drf-response.strategy.ts:53
Parse a DRF 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