Learn R Programming

httr2 (version 1.0.5)

resp_url: Get URL/components from the response

Description

  • resp_url() returns the complete url.

  • resp_url_path() returns the path component.

  • resp_url_query() returns a single query component.

  • resp_url_queries() returns the query component as a named list.

Usage

resp_url(resp)

resp_url_path(resp)

resp_url_query(resp, name, default = NULL)

resp_url_queries(resp)

Arguments

resp

A httr2 response object, created by req_perform().

name

Query parameter name.

default

Default value to use if query parameter doesn't exist.

Examples

Run this code
resp <- request(example_url()) |>
  req_url_path("/get?hello=world") |>
  req_perform()

resp |> resp_url()
resp |> resp_url_path()
resp |> resp_url_queries()
resp |> resp_url_query("hello")

Run the code above in your browser using DataLab