Skip to content
Snippets Groups Projects
Commit 5a57870d authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Check the error before trying to read the response.

parent 5e951c17
No related branches found
No related tags found
No related merge requests found
......@@ -46,12 +46,12 @@ func send(s []byte, token string) (*lib.SignResponse, error) {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
client := &http.Client{}
resp, err := client.Do(req)
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Bad response from server: %s", resp.Status)
}
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Bad response from server: %s", resp.Status)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment