AndersDJohnson / AndersDJohnson/fetch-paginate
feat: next URL as response body field
- Ngôn ngữ chính
- TypeScript
- Star
- 27
- Fork
- 3
- Merge trung bình
- 1 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
Support pulling next URL from response body, such as for HATEOAS APIs.
HATEOAS response might look like:
```json
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"find": { "href": "/orders{?id}", "templated": true }
},
"currentlyProcessing": 14,
"shippedToday": 20
}
```
```ts
fetchPaginate('https://api.example.com', {
getNextUrl: ({ body }) => body?._links?.next?.href
})
```
or possibly support a string path (nicer for CLI):
```ts
fetchPaginate('https://api.example.com', {
getNextUrl: '_links.next.href'
})
```
Not sure how (or whether) to handle templated links.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.