aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-07-05 13:38:35 +0300
committerGitHub <noreply@github.com>2020-07-05 13:38:35 +0300
commite152be099965df95621635a2453f19f90f7223b2 (patch)
tree3605892c05b6a7b72ac3004ce5eeb33e31db70fc
parente08140bf69c10b0bd313da4bce0abdabf29ef709 (diff)
parent63a3e774205bd67f6f08dd33bcbedaf0aecb32c2 (diff)
downloadwhich-ui-e152be099965df95621635a2453f19f90f7223b2.tar.gz
Merge pull request #63 from which-ecosystem/token-bug
Fix token bug
-rw-r--r--src/requests.ts8
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;