Skip to contents

This 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 as next_req in a call to httr2::req_perform_iterative(). This function can usually be generated using one of the iteration helpers described in httr2::iterate_with_offset(). By default, choose_pagination_fn() is used to check for a pagination policy (see req_pagination_policy()), and returns NULL if no such policy is defined.

max_reqs

(length-1 integer) The maximum number of separate requests to perform. Passed to the max_reqs argument of httr2::req_perform_iterative() when next_req is supplied. You will mostly likely want to change the default value (2) to Inf after 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 the max_tries argument of httr2::req_retry().

Value

A list of httr2::response() objects, one for each request performed. The list has additional class nectar_responses.