UNPKG

@opentiny/tiny-toolkit-pro

Version:

TinyPro Vue:开箱即用、前后端分离的 Vue 后台管理模板

25 lines (23 loc) 718 B
import { HwcClient } from '@opentiny/hwc-client'; import { ApigInfo } from '@/types/global'; import BaseUtils from '@/utils/base-utils'; export class HwcClientService { static async apiRequest(fnName: string, params: any, apigInfo: ApigInfo) { return HwcClient.apigClient .exec(apigInfo.apigGroupName, apigInfo.apigName, { query: { fn_name: fnName }, body: JSON.stringify(params), }) .then((rep) => { if (rep.ok) { return rep; } throw new Error(); }) .then((rep) => rep.json()) .then((rep) => (rep.error_code ? { data: [] } : rep)) .catch((err) => { return { data: [] }; }); } }