diff --git a/src/api.rs b/src/api.rs index 757f0be..fc1cdfe 100644 --- a/src/api.rs +++ b/src/api.rs @@ -19,8 +19,8 @@ pub struct Search { pub results: Vec } -pub async fn query_anime() -> Result { - let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1") +pub async fn query_anime(query: String) -> Result { + let resp = reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query)) .await.expect("Failed to get from API") .json::() .await; diff --git a/src/app.rs b/src/app.rs index 44333b5..5f7fa94 100644 --- a/src/app.rs +++ b/src/app.rs @@ -9,8 +9,6 @@ pub type AppResult = std::result::Result>; pub struct App { /// Current value of the input box pub input: Input, - /// Search query - pub query: String, /// Is the app running? pub running: bool, } @@ -19,7 +17,6 @@ impl Default for App { fn default() -> App { App { input: Input::default(), - query: "".to_string(), running: true, } } diff --git a/src/handler.rs b/src/handler.rs index 206f4a0..b6b6f24 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -18,7 +18,7 @@ pub async fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult< } } KeyCode::Enter => { - query_anime().await.unwrap().currentPage; + query_anime(app.input.to_string()).await.unwrap().currentPage; app.input.reset(); } _ => {