# NOT RUN {
x <- HttpRequest$new(url = "https://httpbin.org/get")
## note here how the HTTP method is shown on the first line to the right
x$get()
## assign to a new object to keep the output
z <- x$get()
### get the HTTP method
z$method()
(x <- HttpRequest$new(url = "https://httpbin.org/get")$get())
x$url
x$payload
(x <- HttpRequest$new(url = "https://httpbin.org/post"))
x$post(body = list(foo = "bar"))
HttpRequest$new(
url = "https://httpbin.org/get",
headers = list(
`Content-Type` = "application/json"
)
)
# verb: get any http method
z <- HttpRequest$new(url = "https://httpbin.org/get")
res <- z$verb('get', query = list(hello = "world"))
res$payload
# }
Run the code above in your browser using DataLab