A lightweight library for fetching multiple pages from paginated REST APIs using `fetch`. Supports Link headers (e.g., GitHub), page/offset/limit query parameters, and custom pagination logic. Version 6.1.0 is the current stable release. Ships TypeScript types. Provides both promise-based (`fetchPaginate`) and async iterator (`fetchPaginateIterator`) APIs. Isomorphic (works in Node.js with a fetch polyfill and in the browser). Allows custom `fetch` wrappers for caching. Key differentiator: simple, unopinionated, and works with any fetch-compatible environment.
npm install fetch-paginateNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of fetchPaginate with a GitHub API endpoint, specifying perPage and a getItems function to extract the array from the response body.
Install and import a fetch polyfill: `npm install node-fetch` then `import fetch from 'node-fetch'` before using fetch-paginate.
Implement a deduplication function and pass it as the `merge` option, or process items after fetch.
Use `import` syntax or use dynamic `import('fetch-paginate')`. If you must use `require`, stay on v4.x.Prefer `offset` and `limit` options if your API supports them; fallback to `page` is still functional.
Wrap fetch in a function: `getFetch: () => async (url, init) => fetch(url, init)` or return a cached response.
Ensure `fetch-paginate` is installed (`npm install fetch-paginate`). For TypeScript, set `moduleResolution` to `node16`, `nodenext`, or `bundler` in tsconfig.json.
Install `node-fetch` and import/require it before using fetch-paginate, or use Node.js 18+ (which has global fetch).
Change `import fetchPaginate from 'fetch-paginate'` to `import { fetchPaginate } from 'fetch-paginate'`.Remove `type` from the import: `import { fetchPaginate } from 'fetch-paginate'`.No dependency data recorded yet.