lilei 2 年之前
父节点
当前提交
445657156e
共有 1 个文件被更改,包括 16 次插入5 次删除
  1. 16 5
      src/utils/request.js

+ 16 - 5
src/utils/request.js

@@ -12,7 +12,7 @@ const service = axios.create({
 })
 
 const err = (error) => {
-  console.log(error, error.response,error.message,'error')
+  console.log(error, error.response.data,error.message,'error')
   const config = error.config
   // 网络连接出错
   if (error.message.indexOf('Network Error') >= 0) {
@@ -28,12 +28,23 @@ const err = (error) => {
   // 业务错误提示
   if (error.response) {
     const status = error.response.status
+    const message = error.response.data
     if ((status == 503 || status == 500 || status == 404)) {
       notification.destroy()
-      notification.error({
-        message: '提示',
-        description: error.response.data.message
-      })
+      if(message instanceof Blob){
+        message.text().then(data => {
+          const res = JSON.parse(data)
+          notification.error({
+            message: '提示',
+            description: res.message
+          })
+        })
+      }else{
+        notification.error({
+          message: '提示',
+          description: message
+        })
+      }
     }
     store.commit('SET_loadingStatus', false)
     return Promise.reject(err)