0.1.0 • Published 7 years ago
axios-tool v0.1.0
axios-tool
A command line tool based on axios and framework free.
Usage
npm i axios-tool -gor
yarn global add axios-toolthen
axios-toolOptions
-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.jsajax/index.jswill export an instance ofaxios. There are some initial configuration, you can modify it.- Interceptors of
axiosare placed ininterceptorsdirectory, including request and response interceptors. ref. - There is an
index.jsfile underinterceptors/requestandinterceptors/response, respectively. If you add a new interceptor, please remember add it in correspondingindex.jsfile. 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
7 years ago