It seems like my issue is rather straightforward, but there is definitely something eluding me.
After logging in, I need to store a TOKEN for HTTP requests in a global variable. Upon successful login, the HTTP get method returns an object with the HTTP code (200, 403, 403), a message ("Success"), and the TOKEN. I then pass this object to the HOME.ts page through NavController.
this.navCtrl.setRoot(HomePage,{
data <<--- Object
});
However, when I attempt to assign this "data" to an object of type "Login"
export class Login {
code:number;
token:string;
message:string;
constructor(code?:number, token?:string, message?:string){
this.code = code;
this.token = token;
this.message = message;
}
}
Inserting the attribute Login.token into the global variable results in nothing happening.
I conducted some tests and this is my current understanding.
In the HOME.ts file, I included console logs to investigate further.
console.log(this.navParams.data.data); ----> RESULT 1
console.log(this.navParams.get("data")); ----> RESULT 2
this.dadosRest = this.navParams.get("data");
console.log(this.dadosRest); ----> RESULT 3
console.log(this.dadosRest.token); -----> RESULT 4
RESULTS 1, 2 and 3:
{success: {…}}
success : code : 200 message : "Welcome admin - This is your token (generated by a previous call)" token : "676f71bab54dad7589c3d1b6b5f5b24de0f8c484" proto : Object proto : Object
RESULT 3 :
undefined
Why am I unable to incorporate this returned data into the Login object for processing?