14 lines
447 B
Rust
14 lines
447 B
Rust
use reqwest;
|
|
use crate::types::Channel;
|
|
|
|
pub async fn fetch_channels(domain: &str) -> Option<Vec<Channel>>{
|
|
if let Ok(resp) = reqwest::get(format!("{}/channels/list", domain)).await {
|
|
let bytes = resp.bytes().await.unwrap();
|
|
let res: Result<Vec<Channel>, serde_json::Error> = serde_json::from_slice(&bytes);
|
|
return match res {
|
|
Ok(res) => Some(res),
|
|
_ => None
|
|
};
|
|
}
|
|
return None;
|
|
} |