axios-q
v1.1.5
Published
axios queue
Downloads
12
Maintainers
Readme
axios-q
完整文档请查阅: API 完整文档
推荐使用功能更全面的axios-ex,axios-q 即将停止维护
Install
# use npm
$ npm i axios-q --save
# use yarn
$ yarn add axios-q
Usage
Global configuration
// {app_root}/src/plugins/axios.js
import axiosQueue from 'axios-q'
export default options => {
return new Promise((resolve, reject) => {
axiosQueue
.create(options, {
// cancel request
unique: true,
setHeaders(instance) {
instance.defaults.headers.post['Content-Type'] =
'application/x-www-form-urlencoded'
},
// request
onRequest(config) {
//
return config
},
// requestError
onRequestError(err) {},
// response
onResponse(res) {
if (res.data.success) return res.data
return Promise.reject(res.data)
},
// responseError
onResponseError(err) {},
// error
onError(err) {},
// canceled
onCancel(err) {}
})
.then(res => {
resolve(res)
})
.catch(err => {
reject(err)
})
})
}
Configuration
// ...
Questions & Suggestions
Please open an issue here.