|
|
@ -7,22 +7,30 @@ const request = axios.create({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 添加请求拦截器
|
|
|
|
// 添加请求拦截器
|
|
|
|
request.interceptors.request.use(function (config) {
|
|
|
|
request.interceptors.request.use(
|
|
|
|
return config
|
|
|
|
(config) => {
|
|
|
|
}, function (error) {
|
|
|
|
return config
|
|
|
|
// 对请求错误做些什么
|
|
|
|
},
|
|
|
|
return Promise.reject(error)
|
|
|
|
(error) => {
|
|
|
|
})
|
|
|
|
// 对请求错误做些什么
|
|
|
|
|
|
|
|
return Promise.reject(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 添加响应拦截器
|
|
|
|
// 添加响应拦截器
|
|
|
|
request.interceptors.response.use((response) => {
|
|
|
|
request.interceptors.response.use(
|
|
|
|
return response
|
|
|
|
(response) => {
|
|
|
|
}, (error) => {
|
|
|
|
console.log(response.data)
|
|
|
|
ElMessage({
|
|
|
|
return response.data
|
|
|
|
type: 'error',
|
|
|
|
},
|
|
|
|
message: '出错啦!'
|
|
|
|
(error) => {
|
|
|
|
})
|
|
|
|
ElMessage({
|
|
|
|
return Promise.reject(error)
|
|
|
|
type: 'error',
|
|
|
|
})
|
|
|
|
message: '出错啦!'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
|
|
return Promise.reject(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
export default request
|
|
|
|
export default request
|
|
|
|