In my application I have to use the Email value coming from login to dashboard component(both are individual components).
So in login component I have stored the values in localstorage by using setItem as'
login.component.ts
//somecode
if (loggedIn) {
localStorage.setItem(LocalStorageKey.KEY_CoachGender, this.coachProfile.CoachGender);
localStorage.setItem(LocalStorageKey.KEY_Email, this.coachProfile.Email);
}
and Dashboard.component.ts
let EmailId = localStorage.getItem(LocalStorageKey.KEY_Email);
this.hubConnection.invoke("Register", EmailId)
console.log("Connected")
console.log(EmailId)
But while I am getting the EmailId from loacal Storage I am getting the null value in console Can anyone help me how to get the value without getting the nullvalue
I believe that problem is you don't have considered the asynchronicity, probability you don't wait the logging is done before you insert the result in localStorage