Browse Source

通用请求函数短路逻辑补全

yangxiao 3 years ago
parent
commit
d0f875b43b
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/api/axios.js

+ 2 - 2
src/api/axios.js

@@ -70,7 +70,7 @@ export function requestData (options) {
         store.state.loading = false;
       }
       if (response.code === 200) {
-        options.success(resolve(response));
+        options.success && options.success(resolve(response));
       } else {
         Message.error(response.message || ("请求出错[" + response.code + "]"));
       }
@@ -78,7 +78,7 @@ export function requestData (options) {
       if (options.showLoading) {
         store.state.loading = false;
       }
-      options.fail(reject(error));
+      options.fail && options.fail(reject(error));
     });
   });
 }