0

I am trying to update my Javascript knowledge,

At the moment I am currently developing a Google Chrome extension, I tried to save some information in the local storage, but of course, the data is deleted after close the browser.

I thought in use chrome.storage however for some stupid reason, is not working (manifiest file edited with storage permissions provided)

here my example code :

chrome.storage.local.set({"SRSaved": "ASDASD"}, function(){});
chrome.storage.local.get("SRSaved", function(result){idList = result;}); 

If inside the getter function I print the value of result, is a object and the data is there, ok, however the idList value is undefined, is strange, and , of course idList is declared before

Someone can bring me some light with this problem?

wOxxOm
  • 65,848
  • 11
  • 132
  • 136
  • You are aware that `result` is `{"SRSaved": "ASDASD"}`? Other than that, I'm not seeing what may be off. Could you post more of your code? – Teepeemm Sep 30 '15 at 14:41
  • possible duplicate of [Callback returns undefined with chrome.storage.sync.get](http://stackoverflow.com/questions/18699075/callback-returns-undefined-with-chrome-storage-sync-get) – wOxxOm Sep 30 '15 at 14:55
  • BTW, just googled the exact title of the question and got another answer in top-5 results. – wOxxOm Sep 30 '15 at 14:57
  • there are hundreds of similar dups about async code – Zig Mandel Sep 30 '15 at 17:43
  • 2
    possible duplicate of [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – Zig Mandel Sep 30 '15 at 17:44

0 Answers0