From 135f96cb7971a90e0fc67c5222c0ec030c416b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Mon, 16 Sep 2024 01:25:31 +0200 Subject: [PATCH] Fail more graciously --- R/call.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/call.R b/R/call.R index 0206303..f56e960 100644 --- a/R/call.R +++ b/R/call.R @@ -1,6 +1,10 @@ # prep_esios <- function(path, ..., token = NULL) { token <- get_token(token) + if (!there_is_token(token)) { + return(FALSE) + warning("No token available") + } accept <- c("application/json", "application/vnd.esios-api-v2+json", "application/vnd.esios-api-v1+json") @@ -12,7 +16,9 @@ prep_esios <- function(path, ..., token = NULL) { req_error(body = esios_error) |> req_headers( Accept = paste0(accept, collapse = "; "), - `x-api-key` = token + `Content-Type` = "application/json", + `x-api-key` = token, + .redact = "x-api-key" ) |> req_throttle(10 / 60) }