package main import ( "encoding/json" "fmt" "io" "log" "net/http" "os" ) func (a *App) SimklGetUserWatchlist() SimklWatchList { client := &http.Client{} req, _ := http.NewRequest("GET", "https://api.simkl.com/sync/all-items/anime/watching", nil) req.Header.Add("Content-Type", "application/json") req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken) req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID")) resp, err := client.Do(req) if err != nil { fmt.Println("Errored when sending request to the server") return SimklWatchList{} } defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) var watchlist SimklWatchList err = json.Unmarshal(respBody, &watchlist) if err != nil { log.Printf("Failed at unmarshal, %s\n", err) } return watchlist }