41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import Vue from 'vue'
|
|
import axios from 'axios'
|
|
|
|
// Full config: https://github.com/axios/axios#request-config
|
|
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
|
|
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
|
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
|
|
const config = {
|
|
// baseURL: '/'
|
|
baseURL: window._CONFIG.interfaceUrl,//本地
|
|
// baseURL: 'https://srms.foton.com.cn',//线上
|
|
// timeout: 60 * 1000, // Timeout
|
|
// withCredentials: true, // Check cross-site Access-Control
|
|
}
|
|
|
|
const _axios = axios.create(config)
|
|
|
|
_axios.interceptors.request.use(
|
|
(config) =>
|
|
// Do something before request is sent
|
|
config,
|
|
(error) =>
|
|
// Do something with request error
|
|
Promise.reject(error)
|
|
|
|
)
|
|
|
|
// Add a response interceptor
|
|
_axios.interceptors.response.use(
|
|
(response) =>
|
|
// Do something with response data
|
|
response.data,
|
|
(error) =>
|
|
// Do something with response error
|
|
Promise.reject(error)
|
|
|
|
)
|
|
|
|
export default _axios
|