Skip to contents

Validates that an HTTP response has a success status code (200-299). Throws an informative error on failure.

Usage

http_validate_status(resp, context = NULL)

Arguments

resp

An httr2 response object.

context

Optional character string providing context for error messages.

Value

The response object invisibly (for piping).

See also

Other http-utils: http-utils, http_retry()

Examples

if (FALSE) { # \dontrun{
httr2::request("https://api.example.com") |>
  httr2::req_perform() |>
  http_validate_status(context = "fetching user data")
} # }