refactor: 优化对外的 error 结构

This commit is contained in:
winixt 2022-03-23 11:36:38 +08:00
parent 7cc8ea51eb
commit e7f88b59c3

View File

@ -9,7 +9,11 @@ export default async (ctx, next) => {
if (!config.closeResDataCheck && response && isObject(response.data)) {
const code = response.data.code;
if (code !== '0') {
ctx.error = response; // code 不为零进入 reject
// 尽量保持内部 error 结构和 http 异常的 error 结构一致
ctx.error = {
...response,
response
};
}
}