I have stored an object with multiple properties in localStorage. It does not contain a single value like a string or a number. The name of the localStorage key is UserData
and its value is the following object:
{
key: "1287C31D714BE16FBD44D093E4173CFF"
logTime: "20191013190439"
operatorDni: "46653980"
}
I need to retrieve the value of the object property operatorDni
in order to perform some actions in my code. I have tried to retrieve it using this line of code:
operatorDni: string;
this.operatorDni= localStorage.getItem('UserData.operatorDni');
But I get null
.
How can I get a property of an object in localStorage
with the key? What am I doing wrong?
Thank you very much.