UNPKG

@alicloud/console-fetcher-interceptor-res-biz

Version:
21 lines (20 loc) 784 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createInterceptorResponseFulfilled; var _util = require("../util"); /** * 请求到这里,说明服务端有返回,但业务上不一定是成功的。 * 这里会判断业务是否成功,如果成功则返回从原屎返回中得出的真正的数据,如果失败在抛出 FetchErrorBiz。 */ function createInterceptorResponseFulfilled() { return function (json, fetcherConfig) { // eslint-disable-line @typescript-eslint/no-explicit-any var success = (0, _util.isSuccess)(json, fetcherConfig.isSuccess); if (success) { return (0, _util.getData)(json, fetcherConfig.getData); } throw (0, _util.createFetcherErrorBiz)(json, fetcherConfig); }; }