Reputation: 653
This is for accessing preferences saved in chrome.storage.sync using JavaScript for a Chrome Extension.
Code:
chrome.storage.sync.get('allWeights', function(obj) {
allWeights = obj.allWeights();
chrome.storage.sync.get('allIDs', function(obj2) {
allIDs = obj2.allIDs();
alert("ALL WEIGHTS: " + allWeights);
alert("ALL IDS: " + allIDs);
});
});
Error:
Error in response to storage.get: TypeError: object is not a function at HTMLDocument.restore_options
And the error is pointing to the first line (chrome.storage.sync.get('allWeights').
What is causing this error and how can I fix it?
Upvotes: 2
Views: 1087
Reputation: 653
EDIT: This works
chrome.storage.sync.get(null, function(items) {
allWeights = items.allWeights;
allIDs = items.allIDs;
alert("ALL WEIGHTS: " + allWeights);
alert("ALL IDS: " + allIDs);
});
I had to change items.allWeights() to items.allWeights.
Apparently you can't access an object property with ()
Upvotes: 2