fix: 非 json 格式错误无法展示

This commit is contained in:
CrescentLeaf
2025-11-22 02:07:34 +08:00
parent da4325475c
commit 03f8facde0

View File

@@ -165,8 +165,15 @@ class Client {
body: form,
credentials: 'omit',
})
const text = await (await re.blob()).text()
let json
try {
json = JSON.parse(text)
} catch(_) {}
return {
...await re.json(),
...(json == null ? {
msg: text
} : json),
code: re.status,
} as ApiCallbackMessage
}