| 1 |
# The `fetch` API |
| 2 |
|
| 3 |
[View full source code][code] or [view the compiled example online][online] |
| 4 |
|
| 5 |
[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/fetch/ |
| 6 |
[code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/fetch |
| 7 |
|
| 8 |
This example uses the `fetch` API to make an HTTP request to the GitHub API and |
| 9 |
then parses the resulting JSON. |
| 10 |
|
| 11 |
## `Cargo.toml` |
| 12 |
|
| 13 |
The `Cargo.toml` enables a number of features related to the `fetch` API and |
| 14 |
types used: `Headers`, `Request`, etc. |
| 15 |
|
| 16 |
```toml |
| 17 |
{{#include ../../../examples/fetch/Cargo.toml}} |
| 18 |
``` |
| 19 |
|
| 20 |
## `src/lib.rs` |
| 21 |
|
| 22 |
```rust |
| 23 |
{{#include ../../../examples/fetch/src/lib.rs}} |
| 24 |
``` |