Skip to content

feat: next URL as response body field #3

@AndersDJohnson

Description

@AndersDJohnson

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.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions