#' @export
search_docs <- function(.data, url, method = 'get', ..., parm_fun, npag_fun) {
if(missing(.data)) {
if(!missing(parm_fun)) {
.data = parm_fun(...)
} else {
.data = list(...)
}
}
if(method == 'get') {
r <- httr::GET(url, query = .data,
config = list(ssl.verifypeer = FALSE))
} else if(method == 'post') {
r <- httr::POST(url, body = .data,
config = list(ssl.verifypeer = FALSE))
} else if(is.function(method)) {
r <- method(.data, url, ...)
}
if(r$status_code != 200) {
stop('Request failed.')
}
if(!missing(npag_fun)) {
npag <- npag_fun(r)
} else {
npag <- NULL
}
obj <- structure(
list(result = r, url = url, data = .data, npag = npag, method = method),
class = 'searchdoc'
)
return(obj)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.