aegis-api-proxy
v3.0.3
Published
接口代理
Downloads
7
Readme
aegis-api-proxy
接口代理工具
安装
npm install aegis-api-proxy -S
使用
import ProxyApi from 'aegis-api-proxy';
import axios from 'axios';
import config from '../config';
// 接口描述对象
const apiDescriptor = {
login: {
method: 'POST',
isFormData: true
}
}
axios.defaults.baseURL = config.basePath;
const apiProxy = ProxyApi(apiDescriptor, config, {
headers: {common: {}}
});
export const api = apiProxy;
请求接口
import {api} from './api'
const data = await api.login.r(); // 返回 {code: 0, data: {} | []} 中的data的值
const wrapData = await api.login.req();
const axiosResponse = await api.login.request();