Skip to content

Commit

Permalink
Add catch for fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
steffilazerte committed Nov 6, 2024
1 parent 417a765 commit 4ae687d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@
#'
#' @examples
#' fetch("Steffi LaZerte", type = "mastodon")
#' fetch(c("Steffi LaZerte", "Yanina Bellini Saibene"))
#' fetch("steffilazerte")


fetch <- function(values, type, n = 1) {
fetch <- function(values, type = "mastodon", n = 1) {

if(!type %in% types) {
stop("Incorrect `type`. Must be one of ", paste0(types, collapse = ", "),
call. = FALSE)
}

socials <- cocoon_open()

github <- purrr::map(
stats::setNames(nm = values),
\(x) socials$github[stringr::str_detect(socials$value, x)]) |>
purrr::map(\(x) x[!is.null(x)])
purrr::map(\(x) unique(x[!is.null(x) & !is.na(x)]))

if(any(lengths(github) > 1)) {
warning("Matched multiple ids to ",
Expand Down

0 comments on commit 4ae687d

Please sign in to comment.