Skip to content

Commit

Permalink
Fix make json request
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Dec 6, 2024
1 parent a4b32d4 commit 49e572b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func MakeJSONRequest(method string, url string, body []byte, dest any) (*http.Re

req, _ := httpx.NewRequest(method, url, bytes.NewReader(body), map[string]string{"Content-Type": "application/json"})
resp, err := httpx.Do(http.DefaultClient, req, retryConfig, nil)

if err != nil {
l.Error("error making request", "error", err)
return resp, err
}
originalSize := len(body)

l = l.With("request header", req.Header, "response header", resp.Header)
Expand All @@ -73,10 +76,6 @@ func MakeJSONRequest(method string, url string, body []byte, dest any) (*http.Re

l = l.With("request", formattedJSON.String())

if err != nil {
l.Error("error making request", "error", err)
return resp, err
}
defer resp.Body.Close()

// if we have a body, try to decode it
Expand Down

0 comments on commit 49e572b

Please sign in to comment.