Skip to content

Instantly share code, notes, and snippets.

@kennyjwilli
Created April 4, 2022 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennyjwilli/2be42fbf7172907cf5f1d479627d1578 to your computer and use it in GitHub Desktop.
Save kennyjwilli/2be42fbf7172907cf5f1d479627d1578 to your computer and use it in GitHub Desktop.
(defn json-api-iteration
"Returns a reducible to iterate through a JSON API pagination compliant API.
`request!` is a function of a URI string, expected to return a JSON API response.
`uri` is the statring URI for the paginated endpoint."
[request! uri]
(pages/iteration request!
:initk uri
:vf #(get-in % [:body "data"])
:kf #(get-in % [:body "links" "next"])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment