class User {
public pname: string;
private ptoken: string;
public token_status:boolean = false;
public constructor(pname: string, ptoken: string) {
this.pname = pname;
this.ptoken = ptoken;
}
public Token_Valid() : Promise<token_format>{
return new Promise((accept:any)=>{
db.all("select * from `token` where `name` = $name and `token` = $token;",{$name:this.pname,$token:this.ptoken},(err:any,res:any)=>{
if(res[0]){
accept(res[0]);
}else{
accept({Error:'Person was not found, or token is incorrect soryy ...'})
}
});
})
this.token_status = true;
}
The Following Message is given when I try to assign the boolean value in the method too true
** Could someone explain the reason the error is happening and also how does global variables work in classes inside Typescript / Javascript as in other languages this wouldnt be a problem <3 **