33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
|
|
import axios from "axios";
|
||
|
|
|
||
|
|
if(process.env.NODE_ENV === 'development') {
|
||
|
|
axios.defaults.baseURL = 'http://localhost:890';
|
||
|
|
}else {
|
||
|
|
axios.defaults.baseURL = 'http://192.168.103.200:18990';
|
||
|
|
}
|
||
|
|
//axios.defaults.headers.post['Content-Type'] = 'application/json';
|
||
|
|
//axios.defaults.responseType = 'application/json'
|
||
|
|
axios.defaults.timeout = 5000
|
||
|
|
|
||
|
|
// axios.interceptors.request.use(function (config) {
|
||
|
|
// // 在发送请求之前做些什么
|
||
|
|
// return config;
|
||
|
|
// }, function (error) {
|
||
|
|
// // 对请求错误做些什么
|
||
|
|
// return Promise.reject(error);
|
||
|
|
// });
|
||
|
|
|
||
|
|
// 添加响应拦截器
|
||
|
|
// axios.interceptors.response.use(function (response) {
|
||
|
|
// // 2xx 范围内的状态码都会触发该函数。
|
||
|
|
// // 对响应数据做点什么
|
||
|
|
// return response;
|
||
|
|
// }, function (error) {
|
||
|
|
// // 超出 2xx 范围的状态码都会触发该函数。
|
||
|
|
// // 对响应错误做点什么
|
||
|
|
// console.log('请求发生错误,错误信息:' + error)
|
||
|
|
// return Promise.reject(error);
|
||
|
|
// });
|
||
|
|
//
|
||
|
|
|
||
|
|
export default axios;
|