Hi, has someone tried to make a post from Yew Framework to the back (actix , this part is working) with version 0.19?, sending data in a json format. I have some problems to send it with "wasm_bindgen_futures", that's what doc says.
I have this error:
panicked at 'called `Result::unwrap()` on an `Err` value: JsError(JsError { name: "TypeError", message: "Failed to fetch", js_to_string: "TypeError: Failed to fetch" })'
with this code
let data = Fields {
name: "name".into(),
phone: "999".into(),
email: "email@email.com".into(),
};
let data_serialized = serde_json::to_string_pretty(&data).unwrap();
wasm_bindgen_futures::spawn_local(async move {
let post_request = Request::post("http://127.0.0.1:8000/post_one")
.header("Content-Type", "application/json")
.body(wasm_bindgen::JsValue::from(&data_serialized))
.send()
.await
.unwrap()
.text()
.await
.unwrap();
console::log_1(&JsString::from(post_request))
});