1.0.6 • Published 2 years ago

axios-business v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

axios-business

基础 axios 封装业务 HTTP 库,将接口转化为可调用的函数

usage

browser

<script src="./dist/axios-business.umd.js"></script>;
const modules = {
  app: {
    login: {
      url: "/api/login",
      method: "post",
    },
  },
};

const axiosExt = window["axios-business"];
const apis = axiosExt.createApis({ modules });

node.js

import { createApis } from "axios-business";
const modules = {
  app: {
    login: {
      url: "/api/login",
      method: "post",
    },
  },
};

const apis = createApis({ modules });

API

createApis

function createApis(config: AxiosExtConfig): ApiFunc;

export interface AxiosExtConfig {
  modules: Record<string, ApiModule>;
  timeout?: number;
  interceptor?: {
    request?: (config: AxiosRequestConfig) => AxiosRequestConfig;
    response?: (response: AxiosResponse) => AxiosResponse;
  };
}

export type ApiFunc = {
  [k: string]: {
    [k: string]: (
      data?: FreeObject,
      config?: AxiosRequestConfig
    ) => Promise<any>;
  };
};
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago