更新记录

0.1.1(2021-07-16)

1.初始化版本上传


平台兼容性

介绍

提供api与方法之间关系的配置,减少编写接口调用函数的代码量

使用方法

1.安装

npm install api-config-request

2.创建 api-config.js

import axios from "axios";
import ApiConfigRequest from 'api-config-request';

const config = {
  "multiServer":true,
  "defaultPath":"https://picsum.photos",
  "apis":{
    "test":{
      "getPhotosContent":"GET /{width}/{height}"
    }
  }
}

const apis = ApiConfigRequest.getInstance().setRequests(axios).setApiConfig(config)
export default apis

3.在任意代码文件中引入 api-config.js

import apis from "api-config.js";

const testApi = apis.getModuleApis('test')

// 调用接口
testApi.getPhotosContent({
  width:"200",
  height:"200"
}).then(res=>{
  console.log(res.data);
})
配置项

multiServer: 是否开启多服务模式
defaultPath: 默认访问路径
servers:  多服务路径设置
  "moudle_name": 模块名,对应于api中的模块名
      path: 当前模块需要使用的服务路径,会与apis中的api访问路径做拼接

apis:  api调用关系配置
  "moudle_name": 模块名
      "PromiseFunction" : "method apiPath"   PromiseFunction:为该api调用时的方法名   method:请求方法 apiPath:api访问路径

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问