Is there a way to automatically redirect the page to the home page instead of displaying the login page if there is already a token stored in localStorage? I currently have the following code in the constructor() of app.component.ts, but it still displays the login page first before the request is completed.
statusBar.backgroundColorByHexString('#D32F2F');
splashScreen.hide();
if(localStorage.getItem('token')){
authProvider.silent_login().subscribe(res => {
console.log(res);
if(res.error==0){
this.rootPage = HomePage;
}
})
}