diff --git a/pkg/client/client.go b/pkg/client/client.go index c47b526..0b11092 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "io" "net/http" "github.com/pkg/errors" @@ -95,12 +96,15 @@ func (c *Client) apiDo(ctx context.Context, method string, path string, payload defer res.Body.Close() - decoder := json.NewDecoder(res.Body) - - if err := decoder.Decode(&response); err != nil { + data, err := io.ReadAll(res.Body) + if err != nil { return errors.WithStack(err) } + if err := json.Unmarshal(data, &response); err != nil { + return errors.Wrapf(err, "could not parse json: got '%s'", data) + } + return nil }