Skip to content

Commit

Permalink
Document resps_data() + resp_body_raw() edge case
Browse files Browse the repository at this point in the history
Fixes #621
  • Loading branch information
hadley committed Jan 6, 2025
1 parent dbd27a5 commit 4603e46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 11 additions & 2 deletions R/iterate-responses.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#' @param resps A list of responses (possibly including errors).
#' @param resp_data A function that takes a response (`resp`) and
#' returns the data found inside that response as a vector or data frame.
#'
#' NB: If you're using [resp_body_raw()], you're likely to want to wrap its
#' output in `list()` to avoid combining all the bodies into a single raw
#' vector, e.g. `resps |> resps_data(\(resp) list(resp_body_raw(resp)))`.
#'
#' @examples
#' reqs <- list(
#' request(example_url()) |> req_url_path("/ip"),
Expand All @@ -29,10 +34,14 @@
#' resps |> resps_successes()
#'
#' # collect all their data
#' resps |> resps_successes() |> resps_data(\(resp) resp_body_json(resp))
#' resps |>
#' resps_successes() |>
#' resps_data(\(resp) resp_body_json(resp))
#'
#' # find requests corresponding to failure responses
#' resps |> resps_failures() |> resps_requests()
#' resps |>
#' resps_failures() |>
#' resps_requests()
resps_successes <- function(resps) {
resps[resps_ok(resps)]
}
Expand Down
14 changes: 11 additions & 3 deletions man/resps_successes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4603e46

Please sign in to comment.