import Client from '@blued-core/client'; import InterceptorManager from './interceptor-manager'; export interface Config { url: string; requestId?: string; headers?: { [key: string]: string; }; [key: string]: any; } export default class HttpClient extends Client { interceptors: { request: InterceptorManager; response: InterceptorManager; }; buildClient(key: string): { client: Request; clean(): void; }; } export declare class Request { private getHost; private interceptors; private option; /** * get 请求 * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await get({ url: 'info/update', qs: { id: 123 } }) */ get: (config: Config) => Promise; /** * post 请求 * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await post({ url: 'info/update', body: { id: 123 } }) */ post: (config: Config) => Promise; /** * put 请求 * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await put({ url: 'info/update', qs: { id: 123 } }) */ put: (config: Config) => Promise; /** * delete 请求 * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await delete({ url: 'info/update', body: { id: 123 } }) */ delete: (config: Config) => Promise; /** * get 请求,直接返回 body * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await getData({ url: 'info/update', qs: { id: 123 } }) */ getData: (config: Config) => Promise; /** * post 请求,直接返回 body * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await postData({ url: 'info/update', body: { id: 123 } }) */ postData: (config: Config) => Promise; /** * put 请求,直接返回 body * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await putData({ url: 'info/update', body: { id: 123 } }) */ putData: (config: Config) => Promise; /** * delete 请求,直接返回 body * @param {string} uri 请求的相对路径 * @param {object} config 剩余的参数 * @example await deleteData({ url: 'info/update', body: { id: 123 } }) */ deleteData: (config: Config) => Promise; constructor(getHost: () => string, interceptors: { request: InterceptorManager; response: InterceptorManager; }, option?: Record); /** * request lifecycle * promise chain | ...requestInterceptors -> req -> ...responseInterceptors | */ private superReq; /** * live-data 请求的 base 版本 * @example await req({ url: 'info/update', qs: { id: 123 }, method: 'GET' }) */ private req; }