feat: properly print json response to stdout

This commit is contained in:
2026-04-30 18:03:55 +02:00
parent 1976610833
commit 58687643fb
2 changed files with 10 additions and 5 deletions
+1 -2
View File
@@ -6,12 +6,11 @@ mod rutracker;
slint::include_modules!(); slint::include_modules!();
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
rutracker::search("test");
let ui = AppWindow::new()?; let ui = AppWindow::new()?;
ui.on_request_text_input(|text| { ui.on_request_text_input(|text| {
let text = text.trim();
println!("User input: {}", text); println!("User input: {}", text);
let response = rutracker::search(&text);
}); });
ui.run()?; ui.run()?;
+9 -3
View File
@@ -1,6 +1,12 @@
use serde_json::Value;
#[tokio::main] #[tokio::main]
pub async fn search(value: &str) { pub async fn search(value: &str) -> Result<Value, reqwest::Error> {
let api_url = "https://api.michijackson.xyz/search?q=".to_owned(); let api_url = "https://api.michijackson.xyz/search?q=".to_owned();
let results = reqwest::get(api_url + value).await; let results = reqwest::get(api_url + value).await?;
println!("{:?}", results); let text = results.text().await?;
let v: Value = serde_json::from_str(&text).expect("Failed to parse JSON");
let data = &v["data"];
println!("{:?}", data);
Ok(v)
} }