Skip to content

Commit 2481afd

Browse files
committed
Document pagination
Closes #129
1 parent 0dd9522 commit 2481afd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,21 @@ for await (const event of parseServerSentEvents(response)) {
15421542
}
15431543
```
15441544
1545+
### Pagination
1546+
1547+
Use [`fetch-extras`](https://github.com/sindresorhus/fetch-extras) with Ky for paginating API responses:
1548+
1549+
```js
1550+
import ky from 'ky';
1551+
import {paginate} from 'fetch-extras';
1552+
1553+
const url = 'https://api.github.com/repos/sindresorhus/ky/commits';
1554+
1555+
for await (const commit of paginate(url, {fetchFunction: ky})) {
1556+
console.log(commit.sha);
1557+
}
1558+
```
1559+
15451560
### Extending types
15461561
15471562
Ky's TypeScript types are intentionally defined as type aliases rather than interfaces to prevent global module augmentation, which can lead to type conflicts and unexpected behavior across your codebase. If you need to add custom properties to Ky's types like `KyResponse` or `HTTPError`, create local wrapper types instead:

0 commit comments

Comments
 (0)