backend functioning. Player models init

This commit is contained in:
Ravi Prasad
2025-04-30 21:19:31 -05:00
parent bde752041f
commit e269bc5145
10 changed files with 278 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package utils
import (
"errors"
"io/ioutil"
"net/http"
"time"
)
func GetJSON(url string) ([]byte, error) {
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New("received non-200 response: " + resp.Status)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return body, nil
}