summaryrefslogtreecommitdiff
path: root/webapp/src/main.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-10-06 21:22:44 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-10-06 21:22:44 -0400
commit438594bb2a1838db7d05ae9fdd37adc3ec2ac492 (patch)
tree7e58e46b971d86eb69b0e9dc0b247b459bcc139e /webapp/src/main.rs
parentb10b534ab6507ed2c2d1a62d61f3213397a288e5 (diff)
Test server communication
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>