The fetch
API
View full source code or view the compiled example online
This example uses the fetch
API to make an HTTP request to the GitHub API and
then parses the resulting JSON.
Cargo.toml
The Cargo.toml
enables a number of features related to the fetch
API and
types used: Headers
, Request
, etc.
[package]
authors = ["The wasm-bindgen Developers"]
edition = "2021"
name = "fetch"
publish = false
version = "0.0.0"
[lib]
crate-type = ["cdylib"]
[dependencies]
js-sys = { path = "../../crates/js-sys" }
wasm-bindgen = { path = "../../" }
wasm-bindgen-futures = { path = "../../crates/futures" }
[dependencies.web-sys]
features = ['Headers', 'Request', 'RequestInit', 'RequestMode', 'Response', 'Window']
path = "../../crates/web-sys"
[lints]
workspace = true
src/lib.rs