inst/examples/http-functions-httr.R

# Auto-Generated by `apipkgen` package:
# See apipkgen docs for help

xGET <- function(url, ...) {
  xVERB("GET", url, ...)
}

xPOST <- function(url, ..., body = NULL, encode = "json") {
  body <- ct(body)
  xVERB("POST", url, ..., body = body, encode = encode)
}

xPUT <- function(url, ...) {
  xVERB("PUT", url, ...)
}

xPATCH <- function(url, ...) {
  xVERB("PATCH", url, ...)
}

xDELETE <- function(url, ...) {
  xVERB("DELETE", url, ...)
}

xVERB <- function(verb, url, ...) {
  res <- httr::VERB(verb, url, ...)
  httr::stop_for_status(res)
  httr::content(res, as = "text", encoding = "UTF-8")
}
ropenscilabs/apipkgen documentation built on Aug. 31, 2024, 6:46 p.m.