Expand description
HTTP request and response handling for the browser environment.
§Example
use rustolio::prelude::*;
use rustolio::api::Request;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
struct Data {
field1: String,
}
fn fetch_component() -> Component {
let data: Signal<Option<Data>> = signal(None);
spawn(async move {
let res = Request::get("https://api.example.com/data")
.fetch()
.await
.unwrap()
.json::<Data>()
.await
.unwrap();
data.set(Some(res));
});
move || {
let Some(data) = data.value() else {
return "Loading...".to_string();
};
data.field1
}
}Structs§
Enums§
- Request
Mode - The
RequestModeenum.