Skip to content

Commit

Permalink
fix: should check error before using the response body
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Apr 18, 2024
1 parent dd585ae commit 1509d15
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions utils_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type ResHelper struct {
// Bytes parses body as [*bytes.Buffer] and returns the result
func (res *ResHelper) Bytes() *bytes.Buffer {
res.ut.Helper()
res.ut.err(res.err)
return res.ut.Read(res.Body)
}

Expand All @@ -89,6 +90,7 @@ func (res *ResHelper) String() string {
// JSON parses body as json and returns the result
func (res *ResHelper) JSON() (v interface{}) {
res.ut.Helper()
res.ut.err(res.err)
return res.ut.JSON(res.Body)
}

Expand Down

0 comments on commit 1509d15

Please sign in to comment.