10 lines
368 B
Rust
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)
|
|
}
|