2023-02-26 13:17:19 +08:00
|
|
|
|
|
|
|
|
import axios from 'axios';
|
2023-03-11 15:02:50 +08:00
|
|
|
// import JsonBig from 'json-bigint'
|
2023-02-26 13:17:19 +08:00
|
|
|
const myaxios = axios.create({
|
2023-03-11 01:16:28 +08:00
|
|
|
baseURL:import.meta.env.VITE_APP_BASEAPI,
|
2023-02-26 13:17:19 +08:00
|
|
|
timeout: 50000,
|
|
|
|
|
// transformResponse: [data => {
|
2023-03-11 15:02:50 +08:00
|
|
|
// try {
|
|
|
|
|
// const json = JsonBig({
|
|
|
|
|
// storeAsString: true
|
|
|
|
|
// })
|
|
|
|
|
// return json.parse(data)
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
// // 如果转换失败,则包装为统一数据格式并返回
|
|
|
|
|
// return {
|
|
|
|
|
// data
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2023-02-26 13:17:19 +08:00
|
|
|
// }],
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': 'Bearer ' + ""
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
// 请求拦截器
|
|
|
|
|
myaxios.interceptors.request.use(function (config) {
|
|
|
|
|
return config;
|
|
|
|
|
}, function (error) {
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 响应拦截器
|
|
|
|
|
myaxios.interceptors.response.use(function (response) {
|
|
|
|
|
|
2023-03-11 01:16:28 +08:00
|
|
|
return response.data;
|
2023-02-26 13:17:19 +08:00
|
|
|
}, function (error) {
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
});
|
|
|
|
|
export default myaxios
|