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

138
Views
Cannot set value in chrome.storage

I have no idea why I can't set a value in chrome.storage.sync (same issue with storage.local), I've tried multiple solutions online, but sadly none of them work

This is my popup.js file (linked to the popup.html file)

window.addEventListener("DOMContentLoaded", () => {
    let my_key = "some string";
    let value = "some value"

    chrome.storage.sync.set({[my_key]: value}, function() {
        console.log('Value is set to ' + value);
    });

    chrome.storage.sync.get([my_key], function(result) {
        console.log('Value currently is ' + result.key);
    });
});

Everytime the output is Value currently is undefined.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should use result[my_key] not result.key

chrome.storage.sync.get([my_key], function(result) {
        console.log('Value currently is ' + result[my_key]);
    });
about 4 years ago · Juan Pablo Isaza Report

0

For dynamic keys you have to set the variable in brackets: {[my_key]: value} and also set a value for value.

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!