brick-axios
v0.2.1
Published
axios for brick engine
Downloads
3
Readme
brick-axios
基于brick-engine的axios工具包.
Install
npm install --save brick-axios
npm install --save axios
Usage
Setup
const {defineApplication} = require('brick-engine');
const {axiosSetup} = require('brick-axios');
const app = {};
axiosSetup(app);
defineApplication(exports, app);
Define Axios Instance
const { defineAxios } = require('brick-axios');
const { AXIOS_ID } = require('./constants');
class Module {
}
exports.Module = Module;
defineAxios(Module,{id:AXIOS_ID,config:{baseURL:'http://localhost'}});
Use Axios Instance
const { AXIOS_ID } = require('./constants');
const { defineProviderFactory } = require('brick-engine');
class Service {
constructor(axios) {
this.axios = axios;
}
async create(entity){
const res = await this.axios.post('/simple');
return res.data;
}
}
exports.Service = Service;
defineProviderFactory(Service,{deps:[{id:AXIOS_ID}]});
Documentations
使用jsdoc
生成注释文档
git clone https://github.com/kiba-zhao/brick-axios.git
cd brick-axios
npm install
npm run docs
open docs/index.html