if (FALSE) {
library(promises)
request_base <- request(example_url()) |> req_url_path_append("delay")
p <- request_base |> req_url_path_append(2) |> req_perform_promise()
# A promise object, not particularly useful on its own
p
# Use promise chaining functions to access results
p %...>%
resp_body_json() %...>%
print()
# Can run two requests at the same time
p1 <- request_base |> req_url_path_append(2) |> req_perform_promise()
p2 <- request_base |> req_url_path_append(1) |> req_perform_promise()
p1 %...>%
resp_url_path %...>%
paste0(., " finished") %...>%
print()
p2 %...>%
resp_url_path %...>%
paste0(., " finished") %...>%
print()
# See the [promises package documentation](https://rstudio.github.io/promises/)
# for more information on working with promises
}
Run the code above in your browser using DataLab