Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/apis/create-api/pagination/mod.ts>paginate

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function paginate
import { paginate } from "https://deno.land/x/netzo@0.5.30/apis/create-api/pagination/mod.ts";

Paginate over a fetchPage function

Examples

const fetchPage = async (options: PaginationOptions) => { const { limit, cursor } = options; const response = await fetch(/api/users?limit=${limit}&cursor=${cursor}); const data = await response.json(); return { data, nextCursor: data.length === limit ? encodeCursorCursor(data[data.length - 1].id) : undefined, }; }; const { data, nextCursor, previousCursor } = await paginate(fetchPage, { limit: 50 }); console.log(data, nextCursor, previousCursor);

Parameters

fetchPage: (options: PaginationOptions) => Promise<PaginationResult<T>>