Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Home(props) {
useEffect(() => {
axios.get(API_BASE_URL+'/user/me', { headers: { 'token': localStorage.getItem(ACCESS_TOKEN_NAME) }})
.then(function (response) {
if(response.status !== 200){
redirectToLogin()
}
})
.catch(function (error) {
redirectToLogin()
});
})
function redirectToLogin() {
props.history.push('/login');
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment