Skip to content

Commit 19416e5

Browse files
authored
Update request_funcs.R
1 parent 78ebea1 commit 19416e5

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

R/request_funcs.R

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,31 @@ req_version_1_no_header <- function(url) {
173173
return(inv(resp))
174174
}
175175

176-
req_version_2_w_header <- function(url) {
176+
177+
req_version_2_w_header <- function(url, key = NULL) {
177178
# currently only EVDS request uses this version due to header policy change
178179
# TODO generalize if new source being added
179-
api_key <- get_api_key("evds")
180+
api_key <- key
181+
if (is.null(key)) {
182+
api_key <- get_api_key("evds")
183+
}
180184

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

184-
# req |> httr2::req_dry_run()
185-
suppressWarnings({
186-
resp <- try_or_default(
187-
{
188-
req |> httr2::req_perform()
189-
},
190-
.default = null
191-
)
192188

193-
})
189+
suppressWarnings({
190+
resp <- try_or_default(
191+
{
192+
req |> httr2::req_perform()
193+
},
194+
.default = null
195+
)
196+
})
194197

195198
return(inv(resp))
196199
}
200+
197201
# request_with_param <- function(url) {
198202
# api_key <- get_api_key("evds")
199203
# req <- httr2::request(url)

0 commit comments

Comments
 (0)