|
31 | 31 | #' @param endpoint the endpoint (i.e., location) for the request. |
32 | 32 | #' To see a list of all available endpoints, call `api()`. |
33 | 33 | #' Any relevant query parameters should be included here (see examples). |
34 | | -#' @param verb name of the HTTP verb to use (as in, [httr::VERB()]). |
35 | | -#' @param body body of the HTTP request(as in, [httr::VERB()]). |
| 34 | +#' @param verb name of the HTTP verb to use (as in, [httr::RETRY()]). |
| 35 | +#' @param body body of the HTTP request(as in, [httr::RETRY()]). |
36 | 36 | #' If this value is not already converted to JSON |
37 | 37 | #' (via [jsonlite::toJSON()]), it uses the internal `to_JSON()` |
38 | 38 | #' to ensure values are "automatically unboxed" (i.e., vec. |
39 | 39 | #' |
40 | 40 | #' @param ... For `api()`, these arguments are passed onto |
41 | | -#' [httr::VERB()]. For `api_create()`, these arguments are |
| 41 | +#' [httr::RETRY()]. For `api_create()`, these arguments are |
42 | 42 | #' included in the body of the HTTP request. |
43 | 43 | #' |
44 | 44 | #' @export |
@@ -187,9 +187,16 @@ api <- function(endpoint = "/", verb = "GET", body = NULL, ...) { |
187 | 187 | body <- to_JSON(body) |
188 | 188 | } |
189 | 189 |
|
190 | | - resp <- httr::VERB( |
191 | | - verb = verb, url = url, api_headers(), api_auth(), |
192 | | - body = body, ... |
| 190 | + resp <- httr::RETRY( |
| 191 | + verb = verb, |
| 192 | + url = url, |
| 193 | + api_headers(), |
| 194 | + api_auth(), |
| 195 | + body = body, |
| 196 | + times = 5, |
| 197 | + terminate_on = c(400, 401, 403, 404), |
| 198 | + terminate_on_success = TRUE, |
| 199 | + ... |
193 | 200 | ) |
194 | 201 |
|
195 | 202 | structure(process(resp), class = "api") |
|
0 commit comments