0.2.1 • Published 3 years ago

brick-axios v0.2.1

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

brick-axios

基于brick-engineaxios工具包.

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

License

MIT

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago