AndersDJohnson / AndersDJohnson/fetch-paginate

feat: next URL as response body field

Đang mở
#3 1 bình luận 0 reaction 1 người được giao Được @AndersDJohnson nhận Xem trên GitHub
enhancement hacktoberfest help wanted
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á.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.