Chrome storage responds undefined

44 views Asked by At

I have following function to make reading data from chrome storage easy:

function readExtensionStorage(key, callback) {
var myKey = key;
callback(chrome.storage.local.get(myKey, function (items) {
    if (!chrome.runtime.error) {
        if (JSON.stringify(items) == "{}")
            callback(null);
        else
            callback(items);
    }
}));

}

I'm using the function like following:

readExtensionStorage(proxyName, function (value) {
         console.log(value);
     });

But it responds two time and the first one always undefined. What am i doing false? I have a output like this:

undefined
[Object]
0

There are 0 answers