Undefined
Undefined

Reputation: 764

Output Local Storage Values Via Console?

I was wondering if it is possible to output with console using javascript some values which are stored inside chrome's Local Storage?

Upvotes: 2

Views: 5093

Answers (2)

Nitish Sahu
Nitish Sahu

Reputation: 91

Try something like this:

localStorage.getItem('{attribute name that you want to get}')

In your case you can get the value by using this

localStorage.getItem('se:fkey')

you can also just type localStorage in your chrome console to take a look at the available localstorage

Upvotes: 1

Alex McMillan
Alex McMillan

Reputation: 17952

Sure, just log your item:

console.log(localStorage.getItem('myItemName'));

Round-trip example:

const myThing = {
  name: 'Dave',
  age: 21
};

localStorage.setItem('myThing', JSON.stringify(myThing));
const myThingReturned = JSON.parse(localStorage.getItem('myThing'));

console.log('Before:', myThing);
console.log('After:', myThingReturned);

Upvotes: 4

Related Questions