hotfix+refactor: remove stale value query
, converting input to string
works fine
This commit is contained in:
parent
8227719b67
commit
ff31fa94dc
|
@ -19,8 +19,8 @@ pub struct Search {
|
|||
pub results: Vec<SearchResults>
|
||||
}
|
||||
|
||||
pub async fn query_anime() -> Result<Search, reqwest::Error> {
|
||||
let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1")
|
||||
pub async fn query_anime(query: String) -> Result<Search, reqwest::Error> {
|
||||
let resp = reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query))
|
||||
.await.expect("Failed to get from API")
|
||||
.json::<Search>()
|
||||
.await;
|
||||
|
|
|
@ -9,8 +9,6 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
|
|||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
_ => {
|
||||
|
|
Reference in a new issue