# brick-axios

> axios for brick engine

Latest version **0.2.1** (published 2021-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install brick-axios
pnpm add brick-axios
yarn add brick-axios
bun add brick-axios
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2021-10-25 |
| First published | 2021-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kiba.x.zhao |
| Maintainers | kibamaple |
| Keywords | brick, brick-axios, axios |

## Links

- npm: https://www.npmjs.com/package/brick-axios
- Repository: https://github.com/kiba-zhao/brick-axios
- Homepage: https://github.com/kiba-zhao/brick-axios#readme
- Issues: https://github.com/kiba-zhao/brick-axios/issues
- npm.io page: https://npm.io/package/brick-axios

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.20

## Recent versions

- 0.2.1 (latest) — 2021-10-25
- 0.2.0 — 2021-10-25
- 0.1.3 — 2021-10-20
- 0.1.2 — 2021-10-20
- 0.1.1 — 2021-10-15
- 0.1.0 — 2021-10-15

## README

# brick-axios #
基于[brick-engine](https://github.com/kiba-zhao/brick-engine)的[axios](https://github.com/axios/axios)工具包.

## Install ##

``` shell
npm install --save brick-axios
npm install --save axios
```

## Usage ##

**Setup**

``` javascript

const {defineApplication} = require('brick-engine');
const {axiosSetup} = require('brick-axios');

const app = {};

axiosSetup(app);
defineApplication(exports, app);
```

**Define Axios Instance**

``` javascript

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**

``` javascript

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`生成注释文档

``` shell
git clone https://github.com/kiba-zhao/brick-axios.git
cd brick-axios
npm install
npm run docs
open docs/index.html
```

## License ##
[MIT](LICENSE)

---
_Source: https://npm.io/package/brick-axios · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
