forky_web 0.2.0

Rust Utilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::*;
use anyhow::Result;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use web_sys::*;


pub async fn fetch(url: &str) -> Result<Response> {
	let window = web_sys::window().unwrap();
	let res = JsFuture::from(window.fetch_with_str(url)).await.anyhow()?;
	let res = res.dyn_into().anyhow()?;
	Ok(res)
}