use std::collections::HashMap; use reqwest::header::HeaderMap; #[tokio::main] pub async fn main() -> Result<(), Box> { let res = reqwest::get("https://httpbin.org/ip") .await? .json::>() .await?; println!("Body:\n{:#?}", res); get_bitcoin_price().await?; Ok(()) } pub async fn get_bitcoin_price() -> Result<(), Box> { let url = "https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest"; let mut h = HeaderMap::new(); h.insert("content-type", "application/json".parse().unwrap()); h.insert("X-CMC_PRO_API_KEY","".parse().unwrap()); let mut params = HashMap::new(); params.insert("symbol", "BTC"); let res = reqwest::Client::new() .get(url) .headers(h) .query(¶ms) .send() .await?; println!("BTC Price {:#?}", res); Ok(()) }