This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axiosInstance.interceptors.response.use( | |
response => response, | |
error => { | |
const originalRequest = error.config; | |
if (error.response.status === 401 && error.response.statusText === "Unauthorized" | |
&& error.response.data.code === "token_not_valid") { | |
const refreshToken = localStorage.getItem('refresh_token'); | |
if (refreshToken) { | |
const tokenParts = JSON.parse(atob(refreshToken.split('.')[1])); | |
// exp date in token is expressed in seconds, while now() returns milliseconds: |