feat: add api call file
This commit is contained in:
parent
99c9a1d09f
commit
a6dbb94d90
1 changed files with 17 additions and 0 deletions
17
src/weather/api.rs
Normal file
17
src/weather/api.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use super::data::WeatherData;
|
||||
use super::secret::API_TOKEN;
|
||||
|
||||
|
||||
pub fn get_weather_data() -> reqwest::Result<WeatherData> {
|
||||
let api_url = format!(
|
||||
"https://api.openweathermap.org/data/3.0/onecall?units={units}&lat={lat}&lon={lon}&exclude={exclude}&lang={lang}&appid={token}",
|
||||
units = "metric",
|
||||
lat = 51.03866,
|
||||
lon = 13.70031,
|
||||
exclude = "minutely",
|
||||
lang = "de",
|
||||
token = API_TOKEN,
|
||||
);
|
||||
|
||||
reqwest::blocking::get(dbg!(api_url))?.json()
|
||||
}
|
Loading…
Reference in a new issue