UNPKG

ts-api-core

Version:

Nodejs api framework core

62 lines (61 loc) 2.21 kB
import * as axios from 'axios'; export declare type AxiosResponseType = axios.ResponseType; /** * Http GET/POST 数据 */ export interface IHttpAccess { /** * 接口地址 */ readonly endPoint: string; /** * get请求cle * @param actionPath 接口路径 斜杠开始 * @param params url参数 选填 支持Map对象/普通对象。 * @param headers 请求头 选填 支持Map对象/普通对象。 */ Get: (actionPath: string, params?: any, headers?: any, respType?: AxiosResponseType) => Promise<any>; /** * post请求 * @param actionPath 接口路径 * @param body body参数 * @param params url参数 选填 支持Map对象/普通对象。 * @param headers 请求头 选填 支持Map对象/普通对象。 */ Post: (actionPath: string, body?: any, params?: any, headers?: any, respType?: AxiosResponseType) => Promise<any>; /** * 重新指定接口地址 * @param value */ SetEndPoint: (value: string) => void; /** * 获取完整的 URL * @param actionPath 接口路径。如果本身就包含 `host`,则不使用 `endPoint` 指定的 `host` * @param params 参数 */ GetFullUrl(actionPath: string, params: any): string; } /** * http请求类 用于get/post请求 */ export declare class HttpAccess implements IHttpAccess { private readonly timeOut; /** * Http Access * @param endPoint 接口地址 * @param timeOut 接口超时 单位毫秒 */ constructor(endPoint?: string, timeOut?: number); SetEndPoint(value?: string): void; private TransParams; endPoint: string; Get(actionPath: string, params?: any | undefined, headers?: any | undefined, respType?: AxiosResponseType): Promise<any>; Post(actionPath: string, body?: any | undefined, params?: any | undefined, headers?: any | undefined, respType?: AxiosResponseType): Promise<any>; /** * 获取完整请求路径 * @param actionPath * @param params */ GetFullUrl(actionPath: string, params: any): string; private FormatUrl; }