Skip to content

Commit

Permalink
Add value nil check for requestBody
Browse files Browse the repository at this point in the history
  • Loading branch information
jomei committed Aug 24, 2021
1 parent 86db1d0 commit 1042384
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net/http"
"net/url"
"reflect"
"strconv"
)

Expand Down Expand Up @@ -88,7 +89,7 @@ func (c *Client) request(ctx context.Context, method string, urlStr string, quer
}

var buf io.ReadWriter
if requestBody != nil {
if requestBody != nil && !reflect.ValueOf(requestBody).IsNil() {
body, err := json.Marshal(requestBody)
if err != nil {
return nil, err
Expand Down

0 comments on commit 1042384

Please sign in to comment.