I am trying to save a data object in chrome sync storage and then retrieve it, however the get() function always returns an empty object. The code I am using is,
function storeUserPrefs() {
var key='myKey', testPrefs = {'val': 10};
chrome.storage.sync.set({key: testPrefs}, function() {
console.log('Saved', key, testPrefs);
});
}
function getUserPrefs() {
chrome.storage.sync.get('myKey', function (obj) {
console.log('myKey', obj);
});
}
Could someone please tell me what I am doing wrong here?