From 49e572ba71ee01863b03abaeb0a0382f4238d705 Mon Sep 17 00:00:00 2001 From: Robi9 Date: Fri, 6 Dec 2024 16:19:50 -0300 Subject: [PATCH] Fix make json request --- utils/http.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/http.go b/utils/http.go index 56c4676..f9ef2d0 100644 --- a/utils/http.go +++ b/utils/http.go @@ -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) @@ -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