Skip to content

Commit

Permalink
Update request_funcs.R
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin authored Jan 13, 2025
1 parent 78ebea1 commit 19416e5
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions R/request_funcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,31 @@ req_version_1_no_header <- function(url) {
return(inv(resp))
}

req_version_2_w_header <- function(url) {

req_version_2_w_header <- function(url, key = NULL) {
# currently only EVDS request uses this version due to header policy change
# TODO generalize if new source being added
api_key <- get_api_key("evds")
api_key <- key
if (is.null(key)) {
api_key <- get_api_key("evds")
}

req <- httr2::request(url)
req <- req |> httr2::req_headers(key = api_key)

# req |> httr2::req_dry_run()
suppressWarnings({
resp <- try_or_default(
{
req |> httr2::req_perform()
},
.default = null
)

})
suppressWarnings({
resp <- try_or_default(
{
req |> httr2::req_perform()
},
.default = null
)
})

return(inv(resp))
}

# request_with_param <- function(url) {
# api_key <- get_api_key("evds")
# req <- httr2::request(url)
Expand Down

0 comments on commit 19416e5

Please sign in to comment.