对接后端
This commit is contained in:
parent
3b612cf022
commit
17c33385da
|
@ -34,15 +34,8 @@ service.interceptors.request.use(
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
(response: AxiosResponse) => {
|
(response: AxiosResponse) => {
|
||||||
const { code, message, data } = response.data
|
// 直接返回整个响应数据,而不是只返回 data
|
||||||
|
return response.data
|
||||||
// 根据后端约定的状态码处理
|
|
||||||
if (code === 200) {
|
|
||||||
return data
|
|
||||||
} else {
|
|
||||||
ElMessage.error(message || '请求失败')
|
|
||||||
return Promise.reject(new Error(message || '请求失败'))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
const { status } = error.response || {}
|
const { status } = error.response || {}
|
||||||
|
|
Loading…
Reference in New Issue