Skip to main content
Version: Next

Pagination

PaginationConfig

This type represents the configuration for paginating data in API requests.

PropertyTypeOptionalDescription
pagenumberYesThe current page of results to fetch. Defaults to the first page if not specified.
per_pagenumberYesThe number of results to include per page. Defaults to a predefined value if not specified.

PaginatedData<T>

This type represents a generic structure for paginated responses from an API.

PropertyTypeDescription
dataT[]An array of items of type T representing the paginated data.
pagenumberThe current page number being returned.
total_pagesnumberThe total number of pages available.
total_itemsnumberThe total number of items available across all pages.
per_pagenumberThe number of items included per page.

Example Usage:

type ExampleData = {
id: string;
name: string;
};

const paginatedResponse: PaginatedData<ExampleData> = {
data: [
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
],
page: 1,
total_pages: 5,
total_items: 50,
per_page: 10,
};