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

108
Vistas
How to put JSON object restored from chrome.storage.local into a variable?

I'm trying to build a little chrome extension, and, shortly, I have a popup where the user is prompt to flag/unflag a set of checkboxes. A function than modify a JSON object according to checked/unchecked boxes and later saves it in chrome.storage.local.

So far so good; problems starts at a later stage, when I try to recover the stored data into the content_script. I managed to pass the object into an alert, but, in order for my script to work, I need that JSON to be stored back into a var.

This is the code I inserted in the popup.js and that works fine

chrome.storage.local.set({
        capacity: object
    }, function() {
        console.log('stored with chrome.storage.local');
      });

here's the code I have in the actual script:

var capacity;

load();

function load() {
chrome.storage.local.get('capacity', function(result){
        capacity = result.capacity;
        alert(result.capacity);
}

I'm trying to get capacity to be the same var it was on popup.js when I saved it, but after several attempts I only managed to get the values printed in the alert.

So my question is: is it possible to do this? Where am I getting this wrong?

about 4 years ago · Juan Pablo Isaza
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