2021年3月27日星期六

Trying to access information within localStorage

I am trying to access information with-in localStorage from one component to another, specifically the name of the user on their profile. I am able to access up to the object holding all of the profile information like name, email, address etc. However when I try to extract just the name I am unsure of how to do so, or if its even possible.

right now im trying...

 console.log(localStorage.document)  

this gets me the an object holding all the data in localStorage...

{"name":"John Doe","email":"johndoe@aol.com","phone":"0000000000","address1":"123","address2":"123","addresscitystate":"Seattle, WA","addresszip":"00000"}  

yet I cant seem to access any further then that. I attempted to just do [0] at the end to get the index but im getting just the letter back for that specific index not the actual object I want.

Any advise is appreciated!

https://stackoverflow.com/questions/66837590/trying-to-access-information-within-localstorage March 28, 2021 at 09:10AM

没有评论:

发表评论