Rust Crate - reqwest
Notes on reqwest
Snippets
-
Basic post requestUsing
reqwest-0.11.22
andtokio-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(())
}