Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!