mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
api 支持无status 字段返回
This commit is contained in:
parent
ded3240372
commit
ade2d70bab
@ -164,12 +164,14 @@ function str2function(
|
||||
|
||||
function responseAdaptor(ret: fetcherResult) {
|
||||
const data = ret.data;
|
||||
let hasStatusField = true;
|
||||
|
||||
if (!data) {
|
||||
throw new Error('Response is empty!');
|
||||
} else if (!data.hasOwnProperty('status')) {
|
||||
// 兼容不返回 status 字段的情况
|
||||
data.status = 0;
|
||||
hasStatusField = false;
|
||||
}
|
||||
|
||||
const payload: Payload = {
|
||||
@ -177,7 +179,7 @@ function responseAdaptor(ret: fetcherResult) {
|
||||
status: data.status,
|
||||
msg: data.msg,
|
||||
msgTimeout: data.msgTimeout,
|
||||
data: !data.data && !data.hasOwnProperty('status') ? data : data.data // 兼容直接返回数据的情况
|
||||
data: !data.data && !hasStatusField ? data : data.data // 兼容直接返回数据的情况
|
||||
};
|
||||
|
||||
if (payload.status == 422) {
|
||||
|
Loading…
Reference in New Issue
Block a user