#[function_component(AuthSignUp)]
pub fn render_auth_sign_up() -> Html {
// .......
let onclick = Callback::from(move |_| {
let username = (*username_clone).clone();
let password = (*password_clone).clone();
let user_reg = common::schemas::UserRegister {
username,
password,
email: "yo".to_string()
};
let body = serde_json::to_string(&user_reg).unwrap();
let res = http::Request::get("api/auth/signin")
.body(body)
.unwrap()
.send();
});
html!(
<div class="center auth main-containers" id="auth-container">
<div class="center" style="margin-bottom: 0.5em;">{"enter sign in details"}</div>
<MyInput value={username} r#type="text" class="input center" id="input-username" placeholder="username"/>
<MyInput value={password} r#type="password" class="input center" id="input-password" placeholder="password"/>
<button {onclick}>{"done"}</button>
</div>
)
};
In the following code res is of type impl Future<Output = Result<Response, Error>>
, how can I run this?
I am using yew and the code is inside a function component. I have tried to use
- wasm_bindgen_futures::spawn_local() but it requires that I return nothing
- wasm_bindgen_futures::future_to_promise() but that doesnt work either