diff --git a/cmd/serverFunc.go b/cmd/serverFunc.go index 3308c4b..1e7e73d 100644 --- a/cmd/serverFunc.go +++ b/cmd/serverFunc.go @@ -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) }