Skip to contents

If a request has a pagination policy defined by req_pagination_policy(), extract the pagination_fn from that policy. Otherwise return NULL.

Usage

choose_pagination_fn(req)

Arguments

req

(httr2_request) A httr2::request() object.

Value

The pagination function, or NULL.

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>