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

204
Visualizações
chrome.storage.local.set() is not working properly

I'm having a difficult time dealing with chrome storage. I've looked at the latest documentation for chrome storage and have the following code (this is a code snippet inside an ajax call success function, info.userName is a value returned by my backend program):

chrome.storage.local.set({ "userName": info.userName }, () => {
    chrome.storage.local.get("userName", function(data) {
        console.log(data.userName)
    });
});

but the console.log() always returns undefined, while I'm pretty sure that info.userName has a value. I've also tried this which is not working as well:

chrome.storage.local.set({ "userName": info.userName });
chrome.storage.local.get("userName", function(data) {
    console.log(data.userName)
});

It seems that the set function doesn't save anything locally, does anyone has any thought about this?


Finally figured it out, so my problem is that the value of info.userName is not JSON compatible. After I changed it the first code snippet above works well. Thanks for the comments below!

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

you can do it by these way.....

  • to set item in Local Storage localStorage.setItem("message", "Hi, I am Local Storage...");

  • to get item value from Local Storage localStorage.getItem("message");

  • to remove item from Local Storage localStorage.removeItem("message");

about 4 years ago · Santiago Gelvez 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