make token incase it is empty
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
00d19a95da
commit
0ef6a9b47b
|
@ -54,7 +54,7 @@ func updateToken(ge *pb.Event) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
url := ge.Account.URL + "/auth/login" + "?email=" + ge.Account.Email + "&password=" + ge.Account.Password
|
||||
url := ge.Account.URL + "auth/login" + "?email=" + ge.Account.Email + "&password=" + ge.Account.Password
|
||||
// json := newFetchBody(ge, "POST", url)
|
||||
json := POSTbody(ge, url)
|
||||
|
||||
|
@ -107,22 +107,30 @@ func POSTbody(ge *pb.Event, URL string) string {
|
|||
log.Println("POSTbody() can't make new req")
|
||||
return ""
|
||||
}
|
||||
|
||||
token := ge.Account.Token
|
||||
if (token == "") {
|
||||
token = "POSTbodyEmptyToken"
|
||||
}
|
||||
|
||||
log.Println("POSTbody() ge.Account.Token =", token)
|
||||
req.Header.Set("X-Wit-Auth", ge.Account.Token)
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("Can't exec the req to list networks: %s", err)
|
||||
log.Printf("POSTbody() Can't exec the req to list networks: %s", err)
|
||||
return ""
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("can't read resp")
|
||||
log.Println("POSTbody() can't read resp")
|
||||
return ""
|
||||
}
|
||||
// log.Printf("GETbody() body =", string(body))
|
||||
if body == nil {
|
||||
log.Println("networks is nil")
|
||||
log.Println("POSTbody() body is nil")
|
||||
return ""
|
||||
}
|
||||
log.Println("POSTbody() END body =", string(body))
|
||||
return string(body)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue