Add News widget and integrate NewsAPI for live updates
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user