Skip to content

Instantly share code, notes, and snippets.

@Enigo
Created April 27, 2023 01:48
Show Gist options
  • Save Enigo/4a398963291495f14f7f971d5e7bf969 to your computer and use it in GitHub Desktop.
Save Enigo/4a398963291495f14f7f971d5e7bf969 to your computer and use it in GitHub Desktop.
use serde::de::DeserializeOwned;
pub async fn fetch_single_api_response<T: DeserializeOwned>(endpoint: &str) -> reqwest::Result<T> {
let result = reqwest::get(endpoint).await?.json::<T>().await?;
return Ok(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment