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

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

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