Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@ Whether it's a quick script, or a cross-platform SDK, Surf will make it work.

## Examples
```rust
let mut res = surf::get("https://httpbin.org/get").await?;
dbg!(res.body_string().await?);
#[async_std::main]
async fn main() -> Result<(), surf::Error> {
let mut res = surf::get("https://httpbin.org/get").await?;
dbg!(res.body_string().await?);
Ok(())
}
```

It's also possible to skip the intermediate `Response`, and access the response type directly.
```rust
dbg!(surf::get("https://httpbin.org/get").recv_string().await?);
#[async_std::main]
async fn main() -> Result<(), surf::Error> {
dbg!(surf::get("https://httpbin.org/get").recv_string().await?);
Ok(())
}
```

Both sending and receiving JSON is real easy too.
Expand Down