diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-07-05 13:38:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 13:38:35 +0300 |
commit | e152be099965df95621635a2453f19f90f7223b2 (patch) | |
tree | 3605892c05b6a7b72ac3004ce5eeb33e31db70fc | |
parent | e08140bf69c10b0bd313da4bce0abdabf29ef709 (diff) | |
parent | 63a3e774205bd67f6f08dd33bcbedaf0aecb32c2 (diff) | |
download | which-ui-e152be099965df95621635a2453f19f90f7223b2.tar.gz |
Merge pull request #63 from which-ecosystem/token-bug
Fix token bug
-rw-r--r-- | src/requests.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/requests.ts b/src/requests.ts index b02329d..e1f82b4 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -12,6 +12,14 @@ requests.interceptors.request.use(config => { return _.set(config, 'headers.Authorization', token); }); +requests.interceptors.response.use(response => response, error => { + if (error.message === 'Request failed with status code 401' && localStorage.getItem('token')) { + localStorage.setItem('shouldClear', 'true'); + window.location.reload(); + } + return Promise.reject(error); +}); + export const { get, post, put, patch } = requests; |