Extract a pagination policy from a request
Source:R/req_pagination_policy.R
choose_pagination_fn.Rd
If a request has a pagination policy defined by req_pagination_policy()
,
extract the pagination_fn
from that policy. Otherwise return NULL
.
Arguments
- req
(
httr2_request
) Ahttr2::request()
object.
Examples
req <- httr2::request("https://example.com")
req <- req_pagination_policy(req, httr2::iterate_with_offset("page"))
choose_pagination_fn(req)
#> function (resp, req)
#> {
#> if (!is.null(resp_pages) && !known_total) {
#> n <- resp_pages(resp)
#> if (!is.null(n)) {
#> known_total <<- TRUE
#> signal_total_pages(n)
#> }
#> }
#> if (!isTRUE(resp_complete(resp))) {
#> i <<- i + offset
#> req %>% req_url_query(`:=`(!!param_name, i))
#> }
#> }
#> <bytecode: 0x562b3fd89810>
#> <environment: 0x562b3fd8c108>