import { AxiosResponse } from 'axios'; import { ApiClient } from './api.client'; import { ClientOptions } from './api.client.factory'; import { isNullOrUndefined } from 'util'; export class CloudtApiClient extends ApiClient { constructor( protected options: ClientOptions ) { super( options.baseUrl, options.headerProcessor, (resp: AxiosResponse) => { const data = resp.data; if (isNullOrUndefined(data.code)) { return data; } else { if (data.code === 0) { return data.data; } else { throw new Error('ReturnCode = 0 但数据为 null'); } } }, options.errorHandler ); } } export interface CloudtApiResponse { msg: string; data: any; code: number; }