Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir and Gleam, Reading, and Design. She/Her. If you're looking for experienced talent, I would love to chat. Published on

Rust Crate - reqwest

Notes on reqwest

Snippets

  • Basic post requestUsing reqwest-0.11.22 and tokio-1.33.0.
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut map = HashMap::new();
    map.insert("message", "rust");
    map.insert("datetime", "2023-10-14T16:43:41");

    let client = reqwest::Client::new();
    let res = client
        .post("http://localhost:4000/api/notification")
        .json(&map)
        .send()
        .await?;
    println!("{:#?}", res);
    Ok(())
}