@alicloud/console-fetcher-interceptor-res-risk
v1.7.0
Published
@alicloud/console-fetcher 响应拦截 - 风控
Downloads
869
Keywords
Readme
@alicloud/console-fetcher-interceptor-res-risk
@alicloud/console-fetcher
的响应拦截器 - 风控
包含旧版的主账号风控、新版的主账号风控、新版的子账号风控三部分逻辑。
INSTALL
tnpm i @alicloud/console-fetcher-interceptor-res-biz @alicloud/console-fetcher-interceptor-res-risk -S
注意,风控拦截器依赖 @alicloud/console-fetcher-interceptor-res-biz
对响应进行拦截并抛出业务级别的 Error。
API
import createFetcher, {
Fetcher
} from '@alicloud/fetcher';
// import interceptors 1
import interceptBiz from '@alicloud/console-fetcher-interceptor-res-biz'; // 必需在风控拦截之前
// import interceptors 2
import interceptRisk from '@alicloud/console-fetcher-interceptor-res-risk';
// import interceptors 3
const fetcher: Fetcher = createFetcher();
// ... add interceptors 1
interceptBiz(fetcher);
// ... add interceptors 2
interceptRisk(fetcher, { // 自定义属性,均可选
// 从错误 data 中获取对应的信息
// dataPathVerifyUrl?: string;
// dataPathValidators?: string;
// dataPathUserId?: string;
// dataPathExtend?: string;
// dataPathCodeType?: string;
// dataPathVerifyType?: string;
// dataPathVerifyDetail?: string;
// dataPathOldCodeType?: string;
// dataPathOldVerifyType?: string;
// dataPathOldVerifyDetail?: string;
// codeNeedVerify?: string; // 风控 - 需要用验证码进行二次验证
// codeForbidden?: string; // 风控 - 中断业务流程
// codeInvalidInput?: string; // // 验证码错误
});
// ... add interceptors 3
export default fetcher