import axios from 'axios';
console.log(process.env.NODE_ENV);
// 超时设定
axios.defaults.timeout = 30000;
if(process.client){
let baseURL = window.location.origin+'/api_v1'
if( process.env.NODE_ENV === 'production'){
baseURL = 'http://119.23.136.12:8605/api_v1';
axios.defaults.withCredentials = true;
}
axios.defaults.baseURL = baseURL
}
axios.interceptors.request.use(config => {
return config;
}, err => {
// MessagePlugin.error('请求超时');
return Promise.resolve(err);
});
// http response 拦截器
axios.interceptors.response.use(response => {
const data = response.data;
return data;
}, (err) => {
console.log(err)
// MessagePlugin.error(err.toString());
return Promise.reject(err);
});
// get
export const getRequest = (url, params) => {
return axios({
method: 'get',
url: `${url}`,
par
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35