Skip to content

Commit

Permalink
fix: httpConsole reject error message
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Jun 10, 2020
1 parent bb20412 commit 86ca373
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/httpConsole.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
import axios, { AxiosError } from 'axios';
import Cookie from 'js-cookie';
import { clearConsoleCookie, clearConsoleToken, getConsoleToken, toConsoleLogin } from './token';

Expand Down Expand Up @@ -146,9 +146,11 @@ httpConsole.interceptors.response.use(
// reject错误处理
return Promise.reject(new HttpError(data.resMsg || data.msg || data.message, data));
},
error => {
(error: AxiosError) => {
console.error('http:reject', error);
// reject错误处理
return Promise.reject(new HttpError('系统错误'));
const { data } = error.response || {};
const { message = '系统错误', msg, resMsg } = data || {};
return Promise.reject(new HttpError(resMsg || msg || message));
},
);

0 comments on commit 86ca373

Please sign in to comment.