[][src]Module seed::browser::fetch

Fetch API.

Seed Fetch API is very similar to the browser native one.

There is one entry point: fetch function. It can accept both string urls as well as Request.

To get a Response you need to .await fetch:

let response = fetch("/foo").await?;

Then you can check Status and extract body in various formats:

let response = fetch("/foo").await?.check_status()?;
let body: FooStruct = response.json().await?;

Use Request methods to set init options:

fetch(Request::new(url).method(Method::Post)).await

Re-exports

pub use header::Header;
pub use header::Headers;

Modules

header

HTTP headers

Structs

Request

Its methods configure the request, and handle the response. Many of them return the original struct, and are intended to be used chained together.

RequestController

It allows to abort request or disable request's timeout. You can get it by calling method Request.controller.

Response

Response of the fetch request. To get one you need to use fetch function.

Status

Response status.

Enums

FetchError
Method

HTTP Method types.

StatusCategory

Functions

fetch

The main Fetch API function. It fires a HTTP request.

Type Definitions

Result

Convenient type alias.