@iwotech/ddd-request
v1.0.1
Published
### 使用示例 ```js import Request from '@iwotech/ddd-request'
Downloads
15
Readme
请求拦截器
使用示例
import Request from '@iwotech/ddd-request'
/** 配置参数
* @param timeout [number] 请求超时秒数
* @param errorMessage [object] 预置错误信息
* @param beforeRequest [function] 请求前
* @param afterRequest [function] 请求后
* @param showError [function] 显示错误的方法
* @param withToken [function|boolean] 是否携带token
*/
const request = new Request({
// 请求结果 res.showError() 会执行此方法
showError(errorMessage, res){
// this.$message.error(errorMessage)
},
// 可以根据 url 规则,决定是否需要携带token
withToken(url){
return true
}
})
request.post('/url', data, config)