diff --git a/middleware/student.go b/middleware/student.go index f38c2ee..e131b07 100644 --- a/middleware/student.go +++ b/middleware/student.go @@ -220,10 +220,11 @@ func fetchTokenFromAPI(username, password string) (string, error) { fmt.Println(string(reqBodyJson)) returnValue, err := http.Post(url, "application/json", bytes.NewBuffer(reqBodyJson)) if err != nil { - return "", errors.New("获取token失败") + return "", errors.New("获取token失败,无法解析 token URL") } defer returnValue.Body.Close() body, _ := io.ReadAll(returnValue.Body) + fmt.Println(string(body)) // 解析返回的json数据,判断是否有code字段并且code是否为1,如果是,则获取并返回token var result map[string]interface{} json.Unmarshal(body, &result)