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
20 changes: 18 additions & 2 deletions src/web/clients/api/rest-get.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ with [`reqwest::get`] to get list of all users who have marked a GitHub project
[tokio::main] is used to set up the async executor and the process waits for [`reqwest::get`] to complete before
processing the response into User instances.

```rust,edition2018,no_run
to set up the crates required to run this example run

```
cargo new
cargo add reqwest serde tokio
```

edit the Cargo.toml to add features

```
reqwest = { version = "..", features = ["json"] }
serde = { version = "", features = ["derive"] }
tokio = { version = "..", features = ["full"] }
```

```rust,edition2024
use serde::Deserialize;
use reqwest::Error;
use reqwest::header::USER_AGENT;
Expand All @@ -35,7 +50,8 @@ async fn main() -> Result<(), Error> {
.await?;

let users: Vec<User> = response.json().await?;
println!("{:?}", users);
users.iter().for_each(|user| println!("{:?} {}({})", user, user.login, user.id));

Ok(())
}
```
Expand Down