flash button
This commit is contained in:
parent
f04732e4ca
commit
c4aa9353a8
|
@ -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>
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue