Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RETRY instead of GET #45

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/phs_GET.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
#' @inheritParams request_url
#' @param verbose TRUE or FALSE. If TRUE, a success message will be printed to the console.
#' @return content of a httr::GET request
#'
phs_GET <- function(action, query, verbose = FALSE) {
# define URL
url <- request_url(action, query)

# attempt GET request
response <- httr::GET(
# Attempt GET request, gently retrying up to 3 times
response <- httr::RETRY(
verb = "GET",
url = url,
user_agent = httr::user_agent(
"https://github.com/Public-Health-Scotland/phsmethods"
)
)

# Check for response from server
# Check for a response from the server
if (!inherits(response, "response")) {
cli::cli_abort(c(
"Can't connect to the CKAN server.",
i = "Check your network/proxy settings."
))
}

# extract content from HTTP response
# Extract the content from the HTTP response
content <- httr::content(
response
)
Expand Down
Loading