Files
open-meteo-cli/src/ip_api/ip_api_api.rs
T
midefos 1affcb9d1a
ci/woodpecker/push/woodpecker Pipeline was successful
Correct stdout, updating lib and some clippy clean
2023-07-30 18:13:42 +02:00

10 lines
368 B
Rust

use crate::ip_api::ip_location::IpLocation;
pub fn extract_coords_and_city(ip: &str) -> Result<IpLocation, ureq::Error> {
let url = format!("http://ip-api.com/json/{}?fields=16592", ip);
let body: serde_json::Value = ureq::get(&url).call()?.into_json()?;
let current_weather: IpLocation = serde_json::from_value(body).unwrap();
Ok(current_weather)
}