function checkToken(){ instance.get("token", { withCredentials: true}) .then(function(response) { if(location.href.pathname == "/") { location.href="/html/home.html"; } }) .catch(function(error){ location.href="/"; }); }