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

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

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 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