0.1.0 • Published 5 years ago
axios-tool v0.1.0
axios-tool
A command line tool based on axios
and framework free.
Usage
npm i axios-tool -g
or
yarn global add axios-tool
then
axios-tool
Options
-o, --ouput: The output path. Default value is current path. It will not override the existing ajax
directory.
Structure of output
└── ajax
├── index.js
└── interceptors
├── index.js
├── request
│ └── index.js
└── response
└── index.js
ajax/index.js
will export an instance ofaxios
. There are some initial configuration, you can modify it.- Interceptors of
axios
are placed ininterceptors
directory, including request and response interceptors. ref. - There is an
index.js
file underinterceptors/request
andinterceptors/response
, respectively. If you add a new interceptor, please remember add it in correspondingindex.js
file. According to the source code ofaxios
, It follows FILE (First In Last Execute) rule on request interceptors, and follows FIFE (First In Last Execute) rule on response interceptors. Therefore, you may pay more attension on the order of different type of interceptors. - Also, the success callback function should be the value of
onFulfilled
, and failure callback function should be the value ofonRejected
.
export default {
onFulfilled: config => {
// success logic
},
onRejected: reject => {
// failure logic
}
}
0.1.0
5 years ago