R/http.R

Defines functions .parse .http_post

.http_post <- function(api, body) {
  response <- httr::POST(api, body = body)
  if (httr::http_type(response) != "application/json") {
    stop("API did not return json", call. = FALSE)
  }
  return (.parse(response))
}

.parse <- function(response) {
  return (httr::content(response, "parsed"))
}
johardi/commondata-r documentation built on July 7, 2021, 11:24 p.m.