Request get to api.github.con
⚓ Rust 📅 2026-04-13 👤 surdeus 👁️ 5I use crate reqwest for have request to api.github.com, the code i use this
use reqwest::header::USER_AGENT;
#[tokio::main]
#[allow(unused_variables)]
pub async fn get_user(name_user_github: String) {
let mut uri: String = String::from("https://api.github.com/users/");
uri.push_str(name_user_github.as_str());
uri.push_str("/events");
let client = reqwest::Client::new();
let body = client
.get(uri)
.header(USER_AGENT, "github-user-activity")
.send()
.await
.unwrap()
.text()
.await
.unwrap();
println!("{:?}", body);
}
i like feedback about code for improving and too also use the error,
I'am so sorry for me english.
Thank you for people me can help
2 posts - 2 participants
🏷️ Rust_feed