0
#[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

  1. wasm_bindgen_futures::spawn_local() but it requires that I return nothing
  2. wasm_bindgen_futures::future_to_promise() but that doesnt work either
  • What is `http`? And how is `future_to_promise()` not working? – Chayim Friedman Jun 28 '23 at 13:06
  • Does this answer your question? [How to use a Future as yew::callback::Callback](https://stackoverflow.com/questions/75107941/how-to-use-a-future-as-yewcallbackcallback) – Chayim Friedman Jun 28 '23 at 13:08
  • 1
    @ChayimFriedman [How to make an HTTP request using wasm_bindgen_futures inside a yew struct component that updates the state](https://stackoverflow.com/questions/73408722/how-to-make-an-http-request-using-wasm-bindgen-futures-inside-a-yew-struct-compo) this does – PranshuTheGamer Jun 28 '23 at 14:54

0 Answers0