summaryrefslogtreecommitdiff
path: root/webapp
diff options
context:
space:
mode:
Diffstat (limited to 'webapp')
-rw-r--r--webapp/Cargo.toml2
-rw-r--r--webapp/src/main.rs23
2 files changed, 25 insertions, 0 deletions
diff --git a/webapp/Cargo.toml b/webapp/Cargo.toml
index 91fd87c..13a7e6a 100644
--- a/webapp/Cargo.toml
+++ b/webapp/Cargo.toml
@@ -16,6 +16,8 @@ wee_alloc = "0.4.3"
anyhow = "1.0"
regex = "1.0"
lazy_static = "1.4"
+gloo-net = "0.2.4"
+wasm-bindgen-futures = "0.4.33"
[dev-dependencies]
env_logger = "0.8.4"
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>