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

278
Vistas
how many keys can I retrieve with one call using chrome.storage.local.get?

I have written a simple chrome extension which is pretty much consisting of a popup, the content page and an html page (called 'report') that the extension itself will populate with data when clicking a specific button on the popup.

Long story short, there's a moment when I need to send 2 differents var from the content script to the reports page. I'm using chrome.storage.local.get for this purpose, but it seems that I'm able to retrieve only one of the 2 keys I'm passing.

Here's the code from the content script:

// first part of script where I define what rankingArray and logsArray are

function saveLogs() {
    chrome.storage.local.set({
        ranking: rankingArray
    }, function() {
        console.log("chrome.storage.local.set on rankingArray");
      });

    chrome.storage.local.set({
        logs: logsArray
    }, function() {
        console.log("chrome.storage.local.set on logsArray");
      });
}

and here's the code from the report.js page (acting, obviously, on report.html):

function getRecords() {
    chrome.storage.local.get(['ranking', 'logs'], function(result){
        var obj = result.ranking;
        var test = result.logs + "";
        console.log('logs:\n' + test);  // this one actually print on the console of report.html
        console.log('ranking:\n' + obj); // this one returns empty ('ranking:   ')
        // more stuff to do with obj and test
    });
    console.log("end of - @getRecords()");
}

so I checked the key names and everything several time but I can't figure out what's preventing this from working.
My doubt now is this: is it correct to use chrome.storage.local.get the way I'm doing? Can it retrieve 2 different set of values at the same time?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Question can be closed - as per my comment above the issue was caused by a mistake in the script logic. Basically I had my script reloading the content page before reaching the instructions were rankingArray was filled - once fixed that everything worked as expected.

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