Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/integrations/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.4.42/integrations/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>>