# NOT RUN {
afun <- async(function() {
dx <- http_head("https://eu.httpbin.org/status/200")$
then(function(x) x$status_code)
})
synchronise(afun())
# Check a list of URLs in parallel
afun <- function(urls) {
when_all(.list = lapply(urls, http_head))$
then(function(x) lapply(x, "[[", "status_code"))
}
urls <- c("https://google.com", "https://eu.httpbin.org")
synchronise(afun(urls))
# }
Run the code above in your browser using DataCamp Workspace