resp_link_url: Parse link URL from a response

View source: R/resp-headers.R

resp_link_urlR Documentation

Description

Parses URLs out of the the Link header as defined by RFC 8288.

Usage

resp_link_url(resp, rel)

Arguments

resp

A httr2 response object, created by req_perform().

rel

The "link relation type" value for which to retrieve a URL.

Value

Either a string providing a URL, if the specified rel exists, or NULL if not.

Examples

# Simulate response from GitHub code search
resp <- response(headers = paste0("Link: ",
  '<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2>; rel="next",',
  '<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>; rel="last"'
))

resp_link_url(resp, "next")
resp_link_url(resp, "last")
resp_link_url(resp, "prev")

r-lib/httr2 documentation built on Nov. 4, 2024, 11:32 p.m.