vendredi 27 octobre 2017

Chrome Extension chrome.storage.sync.get() returns empty object

I have following code to store some string value in storage:

function setData(dat) {
chrome.storage.sync.set({'key': dat}, function() {});
 }

function getData() {
chrome.storage.sync.get('key', function (obj) {
    alert('Your code is: ' + obj);
  });
}

And following usage of this code in my content script:

alert('processing');
setData('someVal');
getData();

But "getData" function always returns "object Object" instead of "someVal". What exactly I am doing wrong?




Aucun commentaire:

Enregistrer un commentaire