fix: verifyToken cannot verify valid token
This commit is contained in:
@@ -30,10 +30,15 @@ export default class DevstarAPIHandler {
|
|||||||
// 处理非200响应状态码
|
// 处理非200响应状态码
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const text = await response.text(); // 先读取文本防止json解析失败
|
const text = await response.text(); // 先读取文本防止json解析失败
|
||||||
|
if (response.status == 401) {
|
||||||
|
throw new Error('Token错误')
|
||||||
|
} else {
|
||||||
throw new Error(`HTTP Error: ${response.status} - ${text}`);
|
throw new Error(`HTTP Error: ${response.status} - ${text}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const responseData = await response.json();
|
||||||
|
const data = responseData.data
|
||||||
if (data.username == undefined || data.username == "") {
|
if (data.username == undefined || data.username == "") {
|
||||||
throw new Error('Token对应用户不存在')
|
throw new Error('Token对应用户不存在')
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user