Skip to content

Commit

Permalink
update get request
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagleft committed Dec 29, 2021
1 parent b5bbd0f commit ae13c27
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,26 @@ func (c *Client) sendRequest(requestURL string, requestType string, params url.V
}

func (c *Client) sendGETRequest(requestURL string, params url.Values) ([]byte, error) {
// declare http client
httpClient := &http.Client{}

// create request
urlWithParams := requestURL + "?" + params.Encode()
req, err := http.NewRequest("GET", urlWithParams, nil)
if err != nil {
return nil, err
}

// set cookie
if c.AuthToken != "" {
req.AddCookie(&http.Cookie{
Name: "auth_token",
Value: c.AuthToken,
})
}

// send request
resp, err := http.Get(requestURL + "?" + params.Encode())
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ae13c27

Please sign in to comment.