cnak2
cnak2

Reputation: 1841

I'm missing something in how you view an object from localStorage call

I have the following call to localstorage that I know returns an object of a JWT.

console.log('You have stored the following: ' + window.localStorage.getItem(this.LOCAL_TOKEN_KEY));

But in the consol.log I'm just getting object Object.

I've tried to pars it with .json(), but that doesn't work.

Upvotes: 0

Views: 21

Answers (1)

Narm
Narm

Reputation: 10844

You must pass the key into the getItem method. The getItem() method when given a key will return the keys value.

Try: window.localStorage.getItem('LOCAL_TOKEN_KEY')

https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem

Upvotes: 1

Related Questions