From 7e39cb8d9d5421563c614cb90709cb63642a693c Mon Sep 17 00:00:00 2001 From: ln1778 <465410291@qq.com> Date: Tue, 7 May 2024 11:57:19 +0800 Subject: [PATCH] 22 --- utils/request.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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 = '' }