Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
How to retrieve data from local storage in javascript

i have a class called ui and after saving data in local storage using save method it works but when i'm getting the data with loadData method it gives me undefined .. i want to know why ?!!

class UI{ 

 save(key, value) {
  localStorage.setItem(key, value);
 }

 getValue(key) {
  localStorage.getItem(key);
 }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You didn't mention what's the value you are saving to the localStorage. If it's not a primitive data type, you'd need to convert the value into a string before you save it in the localStorage using the JSON.stringify(value) method and when you run getvalue you'd want to parse the stringified value using JSON.parse(localStorage.getItem(key)).

PS: using static methods make sense when you are trying to save or retrieve data to/from the localStorage. Giving access to individual objects to have access to localStorage might cause problems in the future.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda