diff --git a/utils/request.js b/utils/request.js index a3a3e69..55dd171 100644 --- a/utils/request.js +++ b/utils/request.js @@ -11,7 +11,7 @@ import { MessageBox, Message } from 'element-ui'; // import cancelClass from './cancelToken' const service = axios.create({ - baseURL: window?.VUE_APP_BASE_API?window.VUE_APP_BASE_API:"http://dev-erp-api.xtkj99.com:7890", // api 的 base_url + baseURL: window.VUE_APP_BASE_API?window.VUE_APP_BASE_API:"http://dev-erp-api.xtkj99.com:7890", // api 的 base_url timeout: 1000 * 60 * 2 // 接口超时 }) @@ -164,14 +164,10 @@ service.interceptors.response.use( message: '接口请求超时', type: 'error' }) - } else { - // console.log(Object.getOwnPropertyNames(error)); - // console.log(error); - // console.log(error.stack); - // console.log(error.message); - if(error?.response.config){ - const copyconfig = JSON.parse(JSON.stringify(error?.response.config)) - copyconfig.url = error?.response.config?.url?.replace(copyconfig.baseURL, '') + } else { + if(error.response&&error.response.config){ + const copyconfig = JSON.parse(JSON.stringify(error.response.config)) + copyconfig.url = copyconfig.url.replace(copyconfig.baseURL, '') if (typeof (copyconfig.data) === undefined || copyconfig.data == {} || copyconfig.data == '' || typeof (copyconfig.data) === 'object') { copyconfig.data = '' }