google_place_api/
fetch.rs

1use reqwest;
2use reqwest::Url;
3use serde::de::DeserializeOwned;
4
5type Error = Box<dyn std::error::Error>;
6
7pub async fn fetch<T>(url: &str, params: &[(impl AsRef<str>, impl AsRef<str>)]) -> Result<T, Error>
8where
9    T: DeserializeOwned,
10{
11    let url = Url::parse_with_params(url, params)?;
12
13    let res = reqwest::get(url).await?;
14
15    let output = res.json().await?;
16
17    Ok(output)
18}