Explorar el Código

chore(logging): log http responses separately for code 0 and non-zero codes

sw hace 3 semanas
padre
commit
df30b7a219
Se han modificado 1 ficheros con 13 adiciones y 5 borrados
  1. 13 5
      src/API/interceptor.ts

+ 13 - 5
src/API/interceptor.ts

@@ -51,11 +51,19 @@ axiosInstance.interceptors.request.use(
 // 响应拦截器
 axiosInstance.interceptors.response.use(
   (response) => {
-    console.log('【网络】✅ 响应:', {
-      url: response.config.url,
-      status: response.status,
-      data: response.data,
-    });
+    if (response.data.code !== '0x000000') {
+      console.error('【网络】❌ 响应错误,非"0x000000":', {
+        url: response.config.url,
+        status: response.status,
+        data: response.data,
+      });
+    } else {
+      console.log('【网络】✅ 响应:', {
+        url: response.config.url,
+        status: response.status,
+        data: response.data,
+      });
+    }
     return response;
   },
   (error) => {