diff options
Diffstat (limited to 'src/requests.ts')
-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; |