You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make a post request using the following code, based on the yew docs:
#[derive(Deserialize, Debug, Clone)]
pub struct ReqMsg {
message: String,
code: i32,
}
enum Msg {
Toggle,
Update,
Inaction,
GotReqMsg(Result<ReqMsg, anyhow::Error>),
}
fn upload_my_data(&self, data: &Range) {
let s: String = data.start.to_string().into();
let e: String = data.end.to_string().into();
let ad = Json(json!({
"start": s,
"end": e,
"diff_from_utc": data.diff_from_utc
}));
let post_request = Request::post("/api/range/data")
.header("Content-Type", "application/json")
.body(ad).unwrap();
let callback = self.link.callback(|response: Response<Json<anyhow::Result<ReqMsg, anyhow::Error>>>| {
let Json(data) = response.into_body();
Msg::GotReqMsg(data)
});
let task = FetchService::fetch(post_request, callback).unwrap();
self.fetch_task = Some(task);
ConsoleService::info("Upload callback created");
}
Whereupon I get the following compilation error:
let task = FetchService::fetch(post_request, callback).unwrap();
| ^^^^^^^^^^^^^^^^^^^ the trait `From<Json<serde_json::Value>>` is not implemented for `Result<std::string::String, anyhow::Error>`
I'm unable to understand what's happening here, is this some sort of version incompatibility issue? Is a Result being returned instead of just the value contained within somewhere where it shouldn't be?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to make a post request using the following code, based on the yew docs:
Whereupon I get the following compilation error:
I'm unable to understand what's happening here, is this some sort of version incompatibility issue? Is a
Result
being returned instead of just the value contained within somewhere where it shouldn't be?Beta Was this translation helpful? Give feedback.
All reactions