1 #![cfg(target_arch = "wasm32")]
2 
3 use wasm_bindgen::prelude::*;
4 use wasm_bindgen_test::*;
5 wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
6 
7 #[wasm_bindgen]
8 extern "C" {
9     // Use `js_namespace` here to bind `console.log(..)` instead of just
10     // `log(..)`
11     #[wasm_bindgen(js_namespace = console)]
log(s: &str)12     fn log(s: &str);
13 }
14 
15 #[wasm_bindgen_test]
simple_example()16 async fn simple_example() {
17     let res = reqwest::get("https://hyper.rs")
18         .await
19         .expect("http get example");
20     log(&format!("Status: {}", res.status()));
21 
22     let body = res.text().await.expect("response to utf-8 text");
23     log(&format!("Body:\n\n{}", body));
24 }
25