summaryrefslogtreecommitdiff
path: root/webapp/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/src/main.rs')
-rw-r--r--webapp/src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/webapp/src/main.rs b/webapp/src/main.rs
index 8a1fccc..8b77ea2 100644
--- a/webapp/src/main.rs
+++ b/webapp/src/main.rs
@@ -5,6 +5,7 @@ pub mod bridge_engine;
pub mod card;
pub mod components;
use components::Game;
+use gloo_net::http::Request;
extern crate wee_alloc;
// Use `wee_alloc` as the global allocator.
@@ -19,8 +20,30 @@ fn main() {
#[function_component(App)]
pub fn app() -> Html {
+ let msg = use_state(|| "".to_string());
+ {
+ let msg = msg.clone();
+ use_effect_with_deps(
+ move |_| {
+ wasm_bindgen_futures::spawn_local(async move {
+ msg.set(
+ Request::get("/api/test")
+ .send()
+ .await
+ .unwrap()
+ .json()
+ .await
+ .unwrap(),
+ )
+ });
+ || ()
+ },
+ (),
+ )
+ }
html! {
<>
+ <p>{ &*msg }</p>
<div class="app">
<Game />
</div>