From a6dbb94d909793587d566dfc63aa1b4a5293a11b Mon Sep 17 00:00:00 2001 From: Felix Suchert Date: Mon, 27 Mar 2023 19:12:23 +0200 Subject: [PATCH] feat: add api call file --- src/weather/api.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/weather/api.rs diff --git a/src/weather/api.rs b/src/weather/api.rs new file mode 100644 index 0000000..f5ea487 --- /dev/null +++ b/src/weather/api.rs @@ -0,0 +1,17 @@ +use super::data::WeatherData; +use super::secret::API_TOKEN; + + +pub fn get_weather_data() -> reqwest::Result { + 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() +}