Fixed url formatting in fetch_channels

This commit is contained in:
shockrah 2021-01-18 16:38:41 -08:00
parent e57fd498ae
commit 901e0218dd

View File

@ -2,8 +2,10 @@ use cursive::Cursive;
use reqwest; use reqwest;
use crate::types::Channel; use crate::types::Channel;
pub async fn fetch_channels(domain: &str) -> Option<Vec<Channel>>{ pub async fn fetch_channels(domain: &str, port: u16) -> Option<Vec<Channel>>{
if let Ok(resp) = reqwest::get(&format!("{}/channels/list", domain)).await { let url = format!("http://{}:{}/channels/list", domain, port);
if let Ok(resp) = reqwest::get(&url).await {
let bytes = resp.bytes().await.unwrap(); let bytes = resp.bytes().await.unwrap();
let res: Result<Vec<Channel>, serde_json::Error> = serde_json::from_slice(&bytes); let res: Result<Vec<Channel>, serde_json::Error> = serde_json::from_slice(&bytes);
return match res { return match res {