Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Fixing #37 adding encoding default UTF-8 at httr::content
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatirehbein committed Dec 9, 2020
1 parent 1ad5dc4 commit 5ce58a9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/get_climate_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ get_climate_data <- function(locator,geo_type,type, cvar, start, end){

# print(full_url)

res <- RETRY("GET", full_url, terminate_on = c(404))
res <- RETRY(verb = "GET",
url = full_url,
terminate_on = c(404),
encode = "UTF-8")
stop_for_status(res)
raw_data <- try(content(res, as = "text"), silent = TRUE)
raw_data <- try(content(x = res,
as = "text",
encoding = "UTF-8"),
silent = TRUE)
if(sum(grep("unexpected",raw_data)) > 0){
stop(paste("You entered a country for which there is no data. ",locator," is not a country with any data"))
}
Expand Down

0 comments on commit 5ce58a9

Please sign in to comment.