Use the reqwest crate with async/await to make non-blocking HTTP requests. Add reqwest to your Cargo.toml and call reqwest::get() inside an async function, then .await the response and its body.
use reqwest;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = reqwest::get("https://www.rust-lang.org").await?;
let body = response.text().await?;
println!("{body}");
Ok(())
}
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }