Communicate upstream errors to client

This commit is contained in:
raul 2024-05-08 11:14:30 +02:00
parent cc49c07b1b
commit 212462be3d
1 changed files with 7 additions and 2 deletions

View File

@ -20,10 +20,15 @@ func server() {
}
func returnWeather(c *gin.Context) {
jsonData := getJSON()
jsonData, err := getJSON()
if err != nil {
e := fmt.Sprint(err)
c.String(http.StatusInternalServerError, e)
return
}
textBytes := []byte(jsonData)
aemetRequest := root{}
err := json.Unmarshal(textBytes, &aemetRequest)
err = json.Unmarshal(textBytes, &aemetRequest)
if err != nil {
log.Fatalf("Error occurred unmarshalling data: %v\n", err)
}