Skip to content

Commit

Permalink
Update worldbank urls to use https as https stopped working for reaso…
Browse files Browse the repository at this point in the history
…ns unknown (but on WB's end)
  • Loading branch information
stevecondylios committed Aug 17, 2024
1 parent a28c1fc commit 46b760b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/adjust_for_inflation.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @usage url_all_results(original_url)
#'
#' @param original_url A World Bank API URL. E.g. "http://api.worldbank.org/v2/country".
#' @param original_url A World Bank API URL. E.g. "https://api.worldbank.org/v2/country".
#'
#' @return A character vector
#'
Expand All @@ -20,10 +20,10 @@
#' # Provide a World Bank API URL and `url_all_results` will convert it into one with all results
#' # for that indicator
#' \dontrun{
#' original_url <- "http://api.worldbank.org/v2/country" # Note: no ?format=json on url
#' original_url <- "https://api.worldbank.org/v2/country" # Note: no ?format=json on url
#' url_all_results(original_url)
#' }
#' # "http://api.worldbank.org/v2/country?format=json&per_page=304"
#' # "https://api.worldbank.org/v2/country?format=json&per_page=304"
#'
#'
#'
Expand Down Expand Up @@ -85,7 +85,7 @@ url_all_results <- function(original_url) {

show_countries <- function() {

countries_url <- "http://api.worldbank.org/v2/country?format=json" %>% url_all_results(.)
countries_url <- "https://api.worldbank.org/v2/country?format=json" %>% url_all_results(.)
countries <- countries_url %>% fromJSON(.)

countries <- data.frame(countries[[2]]$iso2Code, countries[[2]]$name, stringsAsFactors = FALSE)
Expand Down Expand Up @@ -311,9 +311,9 @@ retrieve_inflation_data <- function(country, countries_dataframe) {
cat("Retrieving inflation data for", country, "\n")

# Works
# http://api.worldbank.org/v2/country/AU/indicator/FP.CPI.TOTL.ZG?format=json
# https://api.worldbank.org/v2/country/AU/indicator/FP.CPI.TOTL.ZG?format=json

inflation_url <- paste0("http://api.worldbank.org/v2/country/", country, "/indicator/FP.CPI.TOTL.ZG")
inflation_url <- paste0("https://api.worldbank.org/v2/country/", country, "/indicator/FP.CPI.TOTL.ZG")

inflation_url <- inflation_url %>% url_all_results

Expand Down

0 comments on commit 46b760b

Please sign in to comment.