pub fn query(
url: &str,
query_string: &str
) -> Result<String, Box<dyn OtherError>>
Expand description
Fetches the contents of a URL and returns them as a String
.
Arguments
url
- A string slice that holds the URL to fetch.
Returns
This function returns a Result
object that holds a String
with the
contents of the fetched URL, or an error message if the fetch fails.
Examples
let url = "https://httpbin.org/get";
let query = "key1=value1&key2=value2";
match weblib::query(url, query) {
Ok(resp) => println!("{}", resp),
Err(e) => panic!("Error: {}", e),
}