import { AxiosRequestConfig } from 'axios'; import { ResponseError } from './ResponseError'; import { ContextOption, FullyApiConfig, ResponseObject, Runtime } from './types'; export default class Context { url: FullyApiConfig['url']; /** @description 接口请求参数,根据method决定查询的类型,get|option将赋值给query,其他赋值给body */ payload: GPayload; /** @description 接口请求query参数 */ query: FullyApiConfig['query']; /** @description 接口请求url路径参数 */ params: FullyApiConfig['params']; /** @description 接口请求body */ data: FullyApiConfig['data']; /** @description 接口响应的错误 */ error: ResponseError | null; /** @description 接口响应的对象 */ responseObject: ResponseObject | null; /** @description 完整的接口配置项 */ readonly config: FullyApiConfig; readonly axios: Omit & { headers: NonNullable; }; readonly runtime: Runtime; readonly meta: GExtendMeta; /** @description 获取axios的配置项 */ get axiosConfig(): AxiosRequestConfig; constructor({ runtime, defineConfig, requestConfig, payload, }: ContextOption); /** @description 设置请求头 */ setHeader(key: string, value: string): void; setError(err: any, data?: any): void; /** @description 请求前进行一些转化工作 */ beforeRequest(): void; /** @description 转化restful */ private convertRESTful; }