Support pulling next URL from response body, such as for HATEOAS APIs.
HATEOAS response might look like:
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"find": { "href": "/orders{?id}", "templated": true }
},
"currentlyProcessing": 14,
"shippedToday": 20
}
fetchPaginate('https://api.example.com', {
getNextUrl: ({ body }) => body?._links?.next?.href
})
or possibly support a string path (nicer for CLI):
fetchPaginate('https://api.example.com', {
getNextUrl: '_links.next.href'
})
Not sure how (or whether) to handle templated links.
Support pulling next URL from response body, such as for HATEOAS APIs.
HATEOAS response might look like:
{ "_links": { "self": { "href": "/orders" }, "next": { "href": "/orders?page=2" }, "find": { "href": "/orders{?id}", "templated": true } }, "currentlyProcessing": 14, "shippedToday": 20 }or possibly support a string path (nicer for CLI):
Not sure how (or whether) to handle templated links.