Skip to contents

Wrapper around httr2::req_perform() that sends API request and fetches response body. Also, adds relevant object class for use with parsing functions; See dk_resp_parse().

Usage

dk_req_perform(
  req,
  path = NULL,
  verbosity = NULL,
  mock = getOption("httr2_mock", NULL),
  output = c("json", "response"),
  objclass = NULL
)

Arguments

req

A request.

path

Optionally, path to save body of the response. This is useful for large responses since it avoids storing the response in memory.

verbosity

How much information to print? This is a wrapper around req_verbose() that uses an integer to control verbosity:

  • 0: no output

  • 1: show headers

  • 2: show headers and bodies

  • 3: show headers, bodies, and curl status messages.

Use with_verbosity() to control the verbosity of requests that you can't affect directly.

mock

A mocking function. If supplied, this function is called with the request. It should return either NULL (if it doesn't want to handle the request) or a response (if it does). See with_mock()/ local_mock() for more details.

output

One of 'json' or 'response'.

objclass

character. Name of class to assign to output object. Default is NULL, and no additional class is assigned. Used to facilitate parsing; See dk_resp_parse().