Change Root Page based on token storage in sqlite


#1

Hi guys, I have currently experiencing problems. I am trying to change my root page based on stored toke in Sqlite in ionic 3.

Code in the app.component.ts file is below
this.database.check().then((isLoggedIn)=>{
if(isLoggedIn){
this.rootPage = EveHomePage;
}

else {
this.rootPage = SignupPage;
}
});

AND CODE IN THE Database.ts provider is;
check(){
return new Promise((resolve)=>{

        setTimeout(()=>{
          this.db.executeSql("SELECT * from user", [])
    .then(res => {
        if(res.rows.length > 0){
          resolve(true);
        }

else {
resolve(false);
res(true);
}, (e)=>{
console.log(e);
})
}, 3000)
})
}

But apparently it is not working as expected. The if-else condition is not taking effect.
Help needed thanks.