Closed jimrothstein closed 5 months ago
To reduce risk of running this lengthy call by accident or without thinking. ``` file: httr2-pagination.qmd
httr2-pagination-crossref-multi
#| label: **httr2-pagination-crossref-multi** crossref_multi <- crossref_request |> req_retry(max_tries = 3) |> req_perform_iterative( next_req = iterate_with_offset( "offset", resp_pages = \(resp) { content <- resp_body_json(resp) content$pagination$message$`total-results` } ), max_reqs = Inf ) length(crossref_multi) #> [1] 706
I did the following
Added a counter:
e = new.env(emptyenv()) e$counter = 0
Then in callback function, added lines, something like:
# return 4 entries only if (e$counter > 4) return(NULL) e$counter=e$counter+1
That works, but you can also set max_reqs = 4 to do the same thing. I'll be sure to make sure that's clear!
max_reqs = 4
Then it must the cursor that runs everything right away.
To reduce risk of running this lengthy call by accident or without thinking. ``` file: httr2-pagination.qmd
httr2-pagination-crossref-multi
I did the following
Added a counter:
Then in callback function, added lines, something like: