Check out the function below. I can see an object in the console.log using res
:
login2(){
console.log(this.user_form_value);
console.log(this.password_form_value);
this._loginService.login(this.user_form_value, this.password_form_value).subscribe(
res => console.log(res.user),
res2 =>localStorage.setItem("getLoggedInUserANG1",JSON.stringify(res2.user))
)
}
When I attempt to save the same object in local storage, it doesn't get saved. Despite being new to angular, there don't seem to be any bugs and I'm unsure why it's not saving.
After saving it, I also want to retrieve it using getitem
in an array variable and log it to the console. I'm trying to troubleshoot and figure out where exactly I'm making mistakes.
Take a look at the screenshot of my console.log: