Perform a request with opinionated defaults
Source:R/req_perform_opinionated.R
req_perform_opinionated.RdThis function ensures that a request has httr2::req_retry() applied, and
then performs the request, using either httr2::req_perform_iterative() (if
a next_req_fn function is supplied) or httr2::req_perform() (if not).
Usage
req_perform_opinionated(
req,
...,
next_req_fn = choose_pagination_fn(req),
max_reqs = 2,
max_tries_per_req = 3
)Arguments
- req
The first request to perform.
- ...
These dots are for future extensions and must be empty.
- next_req_fn
(
function) An optional function that takes the previous response (resp) and request (req), and returns a new request. This function is passed asnext_reqin a call tohttr2::req_perform_iterative(). This function can usually be generated using one of the iteration helpers described inhttr2::iterate_with_offset(). By default,choose_pagination_fn()is used to check for a pagination policy (seereq_pagination_policy()), and returnsNULLif no such policy is defined.- max_reqs
(
length-1 integer) The maximum number of separate requests to perform. Passed to the max_reqs argument ofhttr2::req_perform_iterative()whennext_reqis supplied. You will mostly likely want to change the default value (2) toInfafter you validate that the request works.- max_tries_per_req
(
length-1 integer) The maximum number of times to attempt each individual request. Passed to themax_triesargument ofhttr2::req_retry().
Value
A list of httr2::response() objects, one for each request
performed. The list has additional class nectar_responses.