From dc91781214ecb9ce871a7dde41e483d39d32bd94 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 2 Dec 2019 15:46:57 -0800 Subject: [PATCH] Works with POST --- api/client.go | 8 ++++---- update/update.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/client.go b/api/client.go index e3e340a17..307dc4245 100644 --- a/api/client.go +++ b/api/client.go @@ -100,9 +100,9 @@ func (c Client) GraphQL(query string, variables map[string]interface{}, data int } // REST performs a REST request and parses the response. -func (c Client) REST(method string, p string, data interface{}) error { +func (c Client) REST(method string, p string, body io.Reader, data interface{}) error { url := path.Join("https://api.github.com/", p) - req, err := http.NewRequest(method, url, nil) + req, err := http.NewRequest(method, url, body) if err != nil { return err } @@ -119,12 +119,12 @@ func (c Client) REST(method string, p string, data interface{}) error { return handleHTTPError(resp) } - body, err := ioutil.ReadAll(resp.Body) + b, err := ioutil.ReadAll(resp.Body) if err != nil { return err } - err = json.Unmarshal(body, &data) + err = json.Unmarshal(b, &data) if err != nil { return err } diff --git a/update/update.go b/update/update.go index b0627789e..de29dcc34 100644 --- a/update/update.go +++ b/update/update.go @@ -38,6 +38,6 @@ func UpdateMessage(client *api.Client) *string { func getLatestRelease(client *api.Client) (*releaseInfo, error) { path := fmt.Sprintf("repos/%s/releases/latest", nwo) var r releaseInfo - err := client.REST("GET", path, &r) + err := client.REST("GET", path, nil, &r) return &r, err }