3.0.3 • Published 3 years ago

aegis-api-proxy v3.0.3

Weekly downloads
34
License
-
Repository
github
Last release
3 years ago

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();
3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

0.1.0-beta2

3 years ago

0.1.0-beta1

3 years ago

0.1.0-beta

3 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago