Function isahc::post_async
source · [−]pub fn post_async<U, B>(uri: U, body: B) -> ResponseFuture<'static>ⓘNotable traits for ResponseFuture<'_>impl Future for ResponseFuture<'_> type Output = Result<Response<AsyncBody>, Error>;
where
Uri: TryFrom<U>,
<Uri as TryFrom<U>>::Error: Into<Error>,
B: Into<AsyncBody>,
Expand description
Send a POST request to the given URI asynchronously with a given request body.
The request is executed using a shared HttpClient
instance. See
HttpClient::post_async
for details.
Examples
use isahc::prelude::*;
let mut response = isahc::post_async("https://httpbin.org/post", r#"{
"speed": "fast",
"cool_name": true
}"#).await?;
let mut body: Vec<u8> = vec![];
response.copy_to(&mut body).await?;
let msg: serde_json::Value = serde_json::from_slice(&body)?;
println!("{}", msg);