async fn fetch<T>(url: String) -> Result<T, Error>
where
    T: DeserializeOwned,
{
    let response = reqwest::get(url).await;
    if let Ok(data) = response {
        if let Ok(repo) = data.json::<T>().await {
            Ok(repo)
        } else {
            Err(Error::DeserializeError)
        }
    } else {
        Err(Error::RequestError)
    }
}
/// You can use reqwest or other crates to fetch your api.
You can use reqwest or other crates to fetch your api.
You can use reqwest or other crates to fetch your api .
async fn fetch<T>(url: String) -> Result<T, Error>
where
    T: DeserializeOwned,
{
    let response = reqwest::get(url).await;
    if let Ok(data) = response {
        if let Ok(repo) = data.json::<T>().await {
            Ok(repo)
        } else {
            Err(Error::DeserializeError)
        }
    } else {
        Err(Error::RequestError)
    }
}
async fn fetch < T > ( url : String ) -> Result < T , Error > where T : DeserializeOwned , { let response = reqwest :: get ( url ) . await ; if let Ok ( data ) = response { if let Ok ( repo ) = data . json :: < T > ( ) . await { Ok ( repo ) } else { Err ( Error :: DeserializeError ) } } else { Err ( Error :: RequestError ) } }
You can use reqwest or other crates to fetch your api.
You can use reqwest or other crates to fetch your api .
url
String
url
String