ant-design-pro
ant-design-pro copied to clipboard
Unhandled Rejection (TypeError): Cannot read properties of null (reading 'success')
是request.ts中的问题(如下)
// 中间件统一错误处理
// 后端返回格式 { success: boolean, data: any }
// 按照项目具体情况修改该部分逻辑
requestMethodInstance.use(async (ctx, next) => {
await next();
const { req, res } = ctx;
// @ts-ignore
if (req.options?.skipErrorHandler) {
return;
}
const { options } = req;
const { getResponse } = options;
const resData = getResponse ? res.data : res;
const errorInfo = errorAdaptor(resData, ctx);
if (errorInfo.success === false) {
// 抛出错误到 errorHandler 中处理
const error: RequestError = new Error(errorInfo.errorMessage);
error.name = 'BizError';
error.data = resData;
error.info = errorInfo;
error.request = req;
error.response = res;
throw error;
}
});
这段代码怎么让其不生效呢?