diff --git a/cmd/standings.go b/cmd/standings.go index 76b3ebf..ca4b4ea 100644 --- a/cmd/standings.go +++ b/cmd/standings.go @@ -18,8 +18,8 @@ package cmd import ( "context" - "encoding/json" "fmt" + "io" "log" "github.com/spf13/cobra" @@ -30,24 +30,28 @@ var league leagueAbbr func standings(cmd *cobra.Command, args []string) { var leagueIds []int32 - leagueIds = append(leagueIds, int32(leagueIDs[string(league)])) + leagueIds = append(leagueIds, leagueIDs[string(league)]) - client := api.NewAPIClient(api.NewConfiguration()) + cfg := api.NewConfiguration() + cfg.Host = "statsapi.mlb.com" + cfg.Scheme = "https" + + client := api.NewAPIClient(cfg) req := client.StandingsAPI.Standings1(context.Background(), "regularSeason") - req.LeagueId(leagueIDs[string(league)]) + req = req.LeagueId(leagueIds) resp, err := req.Execute() if err != nil { log.Fatal(err) } - json, err := json.Marshal(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } - fmt.Println(string(json)) + fmt.Println(string(body)) } // standingsCmd represents the standings command