async tauri command #10324
Answered
by
FabianLars
pan-grayza
asked this question in
Q&A
async tauri command
#10324
-
I have this code which I mixed from tauri and isahc docs: #[tauri::command]
async fn requst_from_web() -> Result<(), isahc::Error> {
let mut response = isahc::get("https://example.org")?;
// let body = response.text()?;
// println!("{}", body);
// Print some basic info about the response to standard output.
println!("Status: {}", response.status());
println!("Headers: {:#?}", response.headers());
// Read the response body as text into a string and print it.
print!("{}", response.text()?);
Ok(())
} Which results in this compiler error that is on
So what I am doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
Jul 23, 2024
Replies: 1 comment
-
It's complaining about the Error. Everything you return from tauri commands must implement |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pan-grayza
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's complaining about the Error. Everything you return from tauri commands must implement
serde::Serialize
and most crate's Error types do not do that. We have an intro on the solution we generally consider best here: https://tauri.app/v1/guides/features/command#error-handling