-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b7468c
commit bf32c78
Showing
6 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
build: | ||
mkdir -p ../view/public/resources | ||
cp -r resources ../view/public | ||
echo "*" > ../view/public/resources/.gitignore | ||
wasm-pack build --target web --out-dir ../view/pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::any::Any; | ||
|
||
use log::info; | ||
use wasm_bindgen::{convert::IntoWasmAbi, JsCast, JsValue}; | ||
use wasm_bindgen_futures::JsFuture; | ||
use web_sys::{Request, RequestInit, RequestMode, Response}; | ||
|
||
pub async fn fetch() -> Result<(), JsValue> { | ||
|
||
info!("fetching"); | ||
|
||
let opts = RequestInit::new(); | ||
opts.set_method("GET"); | ||
opts.set_mode(RequestMode::Cors); | ||
|
||
let url = "localhost:5173/test.txt"; | ||
|
||
let request = Request::new_with_str_and_init(&url, &opts)?; | ||
|
||
let window = web_sys::window().unwrap(); | ||
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?; | ||
|
||
|
||
|
||
// `resp_value` is a `Response` object. | ||
assert!(resp_value.is_instance_of::<Response>()); | ||
let resp: Response = resp_value.dyn_into().unwrap(); | ||
info!("conv"); | ||
let json = JsFuture::from(resp.array_buffer()?).await?.as_string().unwrap(); | ||
|
||
info!("{:?}", json); | ||
info!("ok"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello! |