You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-pc/plugins/axios.js

37 lines
807 B

3 years ago
/*
* @Author: ch
* @Date: 2022-05-03 23:04:45
* @LastEditors: ch
* @LastEditTime: 2022-05-25 17:48:31
3 years ago
* @Description: file content
*/
let axios = null
export default function({app, $axios, req}) {
// if(req){
// let str = 'Safari'
// if(req.headers['user-agent'].includes('Chrome')){
// str = 'Chrome'
// }
// console.log(str, req.headers['cookie'].split('token')[1]);
// }
// export default function ({app, $axios}) {
// $axios.onRequest(()=>{
// })
3 years ago
$axios.onResponse(response => {
const result = response.data;
if(response.status === 200){
if(result.code === 'SUCCESS'){
return result.data;
}
return Promise.reject(result);
}
return Promise.reject({message:'请求出错'});
3 years ago
});
$axios.defaults.timeout = 3000;
3 years ago
axios = $axios;
}
export { axios }