Reqwasm

crates.io docs.rs licence

HTTP requests library for WASM Apps. It provides idiomatic Rust bindings for the web_sys fetch and WebSocket API

Examples

HTTP

rust let resp = Request::get("/path") .send() .await .unwrap(); assert_eq!(resp.status(), 200);

WebSocket

```rust let ws = WebSocket::open("wss://echo.websocket.org").unwrap();

let (mut sender, mut receiver) = (ws.sender, ws.receiver);

spawnlocal(async move { while let Some(m) = receiver.next().await { match m { Ok(Message::Text(m)) => consolelog!("message", m), Ok(Message::Bytes(m)) => console_log!("message", format!("{:?}", m)), Err(e) => {} } } });

spawnlocal(async move { sender.send(Message::Text("test".tostring())).await.unwrap(); }) ```

Contributions

Your PRs and Issues are welcome. Note that all the contribution submitted by you, shall be licensed as MIT or APACHE 2.0 at your choice, without any additional terms or conditions.