Gistlib Logo

gistlib

asynchronous api call in rust

main.rs
use reqwest::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let response = reqwest::get("https://api.example.com").await?;
    let body = response.text().await?;

    println!("Response: {}", body);

    Ok(())
}
232 chars
12 lines

similar rust code snippets

insert an element into an array at a specific index in rust
remove an element from an array at a specific index in rust
remove an element from the middle of an array in rust
find the index of an element in an array in rust
sort an array in rust
remove an element from the beginning of an array in rust
add an element to the beginning of an array in rust
add an element to the end of an array in rust
remove an element from the end of an array in rust
reverse an array in rust

related categories

rust
asynchronous
web-request

gistlibby LogSnag