添加拦截异常状态码

dev
e 4 years ago
parent 2c344afa41
commit 3bbb4a68a6
  1. 15
      src/utils/api.js
  2. 4
      src/utils/http.js

@ -5,6 +5,8 @@ let host2 = 'http://192.168.31.125:9000'//林
let host3 = 'http://192.168.31.140:9000'//7
let host = 'http://192.168.31.137:9000'// 陈赓
export default {
upload:`${host}/nakadai/nakadai/oss/fileUpload`,// 上传文件-订单
logins: `${host}/users/users/user/login`, //登录
verification:`${host}/users/users/user/captcha`,// 验证码
@ -101,6 +103,7 @@ export default {
// 数据管理
getIdQueryTable:`${host1}/data/data/table/getIdQueryTable`,
getTableByClassification:`${host1}/data/data/table/getTableByClassification`,
getTableByCondition:`${host1}/data/data/table/getTableByCondition`,
originalList:`${host1}/data/data/table/originalList`,
@ -113,10 +116,10 @@ export default {
previewData:`${host1}/data/data/preview`,
// 产品管理
deleteProduct:`${host1}/data/data/product/delete`,
findById:`${host1}/data/data/product/findById`,
listByEntity:`${host1}/data/data/product/listByEntity`,
saveProduct:`${host1}/data/data/product/save`,
updateProduct:`${host1}/data/data/product/update`,
saveRecord:`${host1}/data/data/dataRecord/saveRecord`,
deleteProduct:`${host2}/data/data/product/delete`,
findById:`${host2}/data/data/product/findById`,
listByEntity:`${host2}/data/data/product/listByEntity`,
saveProduct:`${host2}/data/data/product/save`,
updateProduct:`${host2}/data/data/product/update`,
saveRecord:`${host2}/data/data/dataRecord/saveRecord`,
}

@ -40,6 +40,10 @@ axios.interceptors.request.use(config => {
axios.interceptors.response.use(
response => {
if (response.status === 200) {
if(response.data.status!==200){// 接口定义的非正常返回的时候,应当处于报错状态
Message.error(response.data.message)
return Promise.reject(response);
}
return Promise.resolve(response);
} else {
Message.error(response.message,'res');

Loading…
Cancel
Save