Screen Link:
https://app.dataquest.io/m/554/working-with-apis-in-r/5/extracting-api-responses-content
I don’t know what I am doing wrong. It doesn’t accept my answer.
My Code:
wb_api_json_get_df <- function(endpoint) {
url <- modify_url("http://api.worldbank.org", path = endpoint)
response <- GET(url)
if ( http_error(response) ){
print(status_code(response))
stop("Something went wrong.", call. = FALSE)
}
if (http_type(response) != "application/json") {
stop("API did not return json", call. = FALSE)
}
json_text<-content(response,as="text")
json_text
}
wb_indicator_json_text <- wb_api_json_get_df("v2/indicator?format=json")