fix: 非 json 格式错误无法展示
This commit is contained in:
@@ -165,8 +165,15 @@ class Client {
|
|||||||
body: form,
|
body: form,
|
||||||
credentials: 'omit',
|
credentials: 'omit',
|
||||||
})
|
})
|
||||||
|
const text = await (await re.blob()).text()
|
||||||
|
let json
|
||||||
|
try {
|
||||||
|
json = JSON.parse(text)
|
||||||
|
} catch(_) {}
|
||||||
return {
|
return {
|
||||||
...await re.json(),
|
...(json == null ? {
|
||||||
|
msg: text
|
||||||
|
} : json),
|
||||||
code: re.status,
|
code: re.status,
|
||||||
} as ApiCallbackMessage
|
} as ApiCallbackMessage
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user