Function weblib::post

source ·
pub fn post(url: &str, data: &str) -> Result<String, Box<dyn OtherError>>
Expand description

Sends a POST request to the specified URL and returns the response as a String.

Arguments

  • url - A string slice that holds the URL to send the request to.
  • data - A string slice that holds the data to send in the request body.

Returns

This function returns a Result object that holds a String with the contents of the response, or an error message if the request fails.

Examples

let url = "https://httpbin.org/post";
let data = "key1=value1&key2=value2";
match weblib::post(url, data) {
    Ok(resp) => println!("{}", resp),
    Err(e) => panic!("Error: {}", e),
}