Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Console.log display object but save in localstorage is [object Object]

I use function parseJwt to convert token, in console it display object, but when i save it in localstorage it display [object Object], and i cant use JSON.parse it in another component

Console.log In localstorage enter image description here

     localStorage.setItem('response', parseJwt(JSON.stringify(response.data.token)));
      console.log(parseJwt(JSON.stringify(response.data.token)));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Local storage only supports storing string. So when you try storing an object like that, it won't work as expected. All you need to do, is stringify the object first:

localStorage.setItem('response', JSON.stringify(parseJwt(JSON.stringify(response.data.token))));

And the reason why you're seeing [object Object], is that [object Object] is the default string representation of a JavaScript Object. You can read more about here https://stackoverflow.com/questions/4750225/what-does-object-object-mean#:~:text=%5Bobject%20Object%5D%20is%20the%20default%20string%20representation%20of%20a%20JavaScript,alert(o)%3B%20%2F%2F%20foo

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!