Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda