flash button

This commit is contained in:
Alex Janka 2023-12-28 13:28:48 +11:00
parent f04732e4ca
commit c4aa9353a8

View file

@ -40,10 +40,25 @@ fn App() -> Html {
html! {<p>{text}</p>}
})
.collect();
let flash = move |_| {
wasm_bindgen_futures::spawn_local(async move {
match reqwasm::http::Request::get(&format!("{API_URL}/flash"))
.send()
.await
{
Ok(response) => match response.json::<shared_types::ChargeState>().await {
Ok(_) => {}
Err(e) => println!("error getting text: {e:#?}"),
},
Err(e) => println!("request error: {e:#?}"),
}
})
};
html! {
<div>
<button {onclick}>{ "refresh" }</button>
{text_elements}
<button onclick={flash}>{ "flash" }</button>
</div>
}
}