Add News widget and integrate NewsAPI for live updates

This commit is contained in:
2025-12-29 21:19:05 +01:00
parent d638a8ae97
commit 9b5afc3d7c
9 changed files with 260 additions and 38 deletions
+9 -4
View File
@@ -4,7 +4,6 @@ import (
"ArinDash/config"
"encoding/json"
"io"
"log"
"net/http"
)
@@ -27,16 +26,22 @@ func FetchCurrentWeather() CurrentWeather {
req, err := http.NewRequest("GET", apiBaseURL+"?id="+cfg.OpenWeatherMap.LocationId+"&units=metric&lang=en&APPID="+cfg.OpenWeatherMap.ApiKey, nil)
if err != nil {
panic(err)
return CurrentWeather{
ErrorMessage: err.Error(),
}
}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
return CurrentWeather{
ErrorMessage: err.Error(),
}
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
return CurrentWeather{
ErrorMessage: err.Error(),
}
}
err = json.Unmarshal(respBody, currentWeather)