update
This commit is contained in:
parent
4775c1aa5b
commit
9297b3b877
@ -228,6 +228,7 @@ func fetchTokenFromAPI(username, password string) (string, error) {
|
|||||||
// 解析返回的json数据,判断是否有code字段并且code是否为1,如果是,则获取并返回token
|
// 解析返回的json数据,判断是否有code字段并且code是否为1,如果是,则获取并返回token
|
||||||
var result map[string]interface{}
|
var result map[string]interface{}
|
||||||
json.Unmarshal(body, &result)
|
json.Unmarshal(body, &result)
|
||||||
|
fmt.Println("code: %d",result["code"])
|
||||||
if _, ok := result["code"]; !ok || result["code"] != 1 {
|
if _, ok := result["code"]; !ok || result["code"] != 1 {
|
||||||
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))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user