Gitlab is now using https://gitlab.lcsb.uni.lu as it's primary address. Please update your bookmarks. FAQ.

Commit d9709d11 authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

helper functions update

parent 8e8b1d48
Pipeline #37202 passed with stages
in 4 minutes and 4 seconds
...@@ -9,14 +9,14 @@ library(httr) ...@@ -9,14 +9,14 @@ library(httr)
library(jsonlite) library(jsonlite)
### A convenience function to handle API queries ### A convenience function to handle API queries
ask_GET <- function(fask_url, verbose = F) { ask_GET <- function(fask_url, verbose = F, encoding = "UTF-8") {
if(verbose) { if(verbose) {
message(URLencode(fask_url)) message(URLencode(fask_url))
} }
resp <- httr::GET(url = URLencode(fask_url), resp <- httr::GET(url = URLencode(fask_url),
httr::add_headers('Content-Type' = "application/x-www-form-urlencoded")) httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"))
if(httr::status_code(resp) == 200) { if(httr::status_code(resp) == 200) {
return(httr::content(resp, as = "text")) return(httr::content(resp, as = "text", encoding = encoding))
} }
return(NULL) return(NULL)
} }
...@@ -64,4 +64,4 @@ get_annotation <- function(freferences, ftype) { ...@@ -64,4 +64,4 @@ get_annotation <- function(freferences, ftype) {
function(x) { function(x) {
ifelse(any(x$type == ftype), x$resource[x$type == ftype], NA) ifelse(any(x$type == ftype), x$resource[x$type == ftype], NA)
}) })
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment