also return error

This commit is contained in:
lyx0 2021-10-17 17:47:56 +02:00
parent 3a827bbd6f
commit c22e4d73bd

View file

@ -8,11 +8,11 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func ApiCall(uri string) string { func ApiCall(uri string) (string, error) {
resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/%s", uri)) resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/%s", uri))
if err != nil { if err != nil {
log.Error(err) log.Error(err)
return "Something went wrong FeelsBadMan" return "Something went wrong FeelsBadMan", err
} }
defer resp.Body.Close() defer resp.Body.Close()
@ -20,7 +20,7 @@ func ApiCall(uri string) string {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
return "Something went wrong FeelsBadMan" return "Something went wrong FeelsBadMan", err
} }
return string(body) return string(body), nil
} }