hotfix+refactor: remove stale value query
, converting input to string
works fine
This commit is contained in:
parent
a77796aee7
commit
784ceda35e
|
@ -19,8 +19,8 @@ pub struct Search {
|
||||||
pub results: Vec<SearchResults>
|
pub results: Vec<SearchResults>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn query_anime() -> Result<Search, reqwest::Error> {
|
pub async fn query_anime(query: String) -> Result<Search, reqwest::Error> {
|
||||||
let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1")
|
let resp = reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query))
|
||||||
.await.expect("Failed to get from API")
|
.await.expect("Failed to get from API")
|
||||||
.json::<Search>()
|
.json::<Search>()
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -9,8 +9,6 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
|
||||||
pub struct App {
|
pub struct App {
|
||||||
/// Current value of the input box
|
/// Current value of the input box
|
||||||
pub input: Input,
|
pub input: Input,
|
||||||
/// Search query
|
|
||||||
pub query: String,
|
|
||||||
/// Is the app running?
|
/// Is the app running?
|
||||||
pub running: bool,
|
pub running: bool,
|
||||||
}
|
}
|
||||||
|
@ -19,7 +17,6 @@ impl Default for App {
|
||||||
fn default() -> App {
|
fn default() -> App {
|
||||||
App {
|
App {
|
||||||
input: Input::default(),
|
input: Input::default(),
|
||||||
query: "".to_string(),
|
|
||||||
running: true,
|
running: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub async fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyCode::Enter => {
|
KeyCode::Enter => {
|
||||||
query_anime().await.unwrap().currentPage;
|
query_anime(app.input.to_string()).await.unwrap().currentPage;
|
||||||
app.input.reset();
|
app.input.reset();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Reference in a new issue