axios-wechat-adapter
Version:
axios微信小程序适配器,可以复用web或者node上的axios请求
19 lines (18 loc) • 1.2 kB
TypeScript
import { Method, AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
import { WechatRequestMethod } from './types';
export declare const isDate: (val?: any) => boolean;
export declare const isJSONstr: (str?: any) => boolean;
export declare const encode: (val: string | number | boolean) => string;
/** 方法转换器 */
export declare const methodProcessor: (axiosMethod: Method) => WechatRequestMethod;
/** url路径转换器 */
export declare const urlProcessor: (baseURL?: string, path?: string, params?: AxiosRequestConfig['params'], paramsSerializer?: AxiosRequestConfig['paramsSerializer']) => string;
export declare const dataProcessor: (data?: any) => any;
/** 正确返回处理器
* 默认情况下 4xx、5xx请求在微信小程序中属于成功的返回
* 因此这里需要对successResult做一次判断过滤
*
*/
export declare const successResProcessor: (resolve: (val: AxiosResponse) => void, reject: (err: AxiosError) => void, res: any, config: AxiosRequestConfig, request: () => void) => void;
/** 错误返回处理器 */
export declare const failResProcessor: (reject: (err: AxiosError) => void, res: any, config: AxiosRequestConfig, request: () => void) => void;