Search code examples
google-chromegoogle-chrome-extension

How to get the value of a key chrome.storage.sync.get chrome extension?


I would like to get the key value chrome.storage.sync.get. Example: Setting the storage;

var domain = url.hostname + ' (' + type + ')';
                  var save = {};
      save[domain] = response;    
chrome.storage.sync.set(save,function() {
    // Notify that we saved.
            chrome.storage.sync.get(save, function (reee) {
    console.log(reee);
});
});

It sets this:

stackoverflow.com (type): "{\n    \"se:fkey\": \"8b52d88db2cc534208b006788551e0e43f25f678f8ff9c2cdcd4e8497143cbdf,1616780921\"\n}"

Then I retrieve it with this:

chrome.storage.sync.get(save, function (reee) {
    console.log(reee);
});

And it responds with this:

stackoverflow.com (type): "{\n    \"se:fkey\": \"8b52d88db2cc534208b006788551e0e43f25f678f8ff9c2cdcd4e8497143cbdf,1616780921\"\n}"

How can I set a variable to this: "{\n "se:fkey": "8b52d88db2cc534208b006788551e0e43f25f678f8ff9c2cdcd4e8497143cbdf,1616780921"\n}" after retrieving it.

Ask me if you need more explanation.


Solution

  • wOxxOm Fixed It!!!!!!!!!!! He said:

    var foo = reee['stackoverflow.com (type)']
    

    foo is the variable for: "{\n "se:fkey": "8b52d88db2cc534208b006788551e0e43f25f678f8ff9c2cdcd4e8497143cbdf,1616780921"\n}"