update
This commit is contained in:
parent
9297b3b877
commit
05d2325685
@ -230,10 +230,11 @@ func fetchTokenFromAPI(username, password string) (string, error) {
|
|||||||
json.Unmarshal(body, &result)
|
json.Unmarshal(body, &result)
|
||||||
fmt.Println("code: %d",result["code"])
|
fmt.Println("code: %d",result["code"])
|
||||||
if _, ok := result["code"]; !ok || result["code"] != 1 {
|
if _, ok := result["code"]; !ok || result["code"] != 1 {
|
||||||
|
fmt.Println(ok)
|
||||||
return "", errors.New("fetchTokenFromAPI:获取token失败,token无效,code:"+fmt.Sprintf("%d", int(result["code"].(float64)))+" message:"+result["message"].(string))
|
return "", errors.New("fetchTokenFromAPI:获取token失败,token无效,code:"+fmt.Sprintf("%d", int(result["code"].(float64)))+" message:"+result["message"].(string))
|
||||||
}
|
}
|
||||||
// 如果不存在message字段,或message字段的值为空,则token为空
|
// 如果不存在message字段,或message字段的值为空,则token为空
|
||||||
if _, ok := result["message"]; !ok || result["message"] == "" {
|
if _, ok := result["result"]; !ok || result["result"] == "" {
|
||||||
return "", errors.New("获取token失败,token为空")
|
return "", errors.New("获取token失败,token为空")
|
||||||
}
|
}
|
||||||
return result["message"].(string), nil
|
return result["message"].(string), nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user