Skip to content

Commit

Permalink
rework body builded
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag committed Jun 26, 2022
1 parent e16377a commit 5b1b105
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tgstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@ var NewRestRequest = func(c *Client, ctx context.Context, token, method, urlPath
return nil, errors.New("token not found")
}

//var body string
body := url.Values{}
data["token"] = token

for key, value := range data {
body.Add(key, value)
}

body.Add("token", token)
reqBodyData := body.Encode()
reqBodyData, _ := json.Marshal(data)
// On `GET`, move the payload into the URL
if method == http.MethodGet {
//var body string
body := url.Values{}
for key, value := range data {
body.Add(key, value)
}
body.Add("token", token)
uri += "?" + body.Encode()
reqBodyData = ""
reqBodyData = nil
}

req, err := http.NewRequest(method, uri, strings.NewReader(reqBodyData))
req, err := http.NewRequest(method, uri, bytes.NewReader(reqBodyData))

if err != nil {
return nil, err
Expand Down

0 comments on commit 5b1b105

Please sign in to comment.