What i wanna achieve, from popup save data to local storage, then when next time i open the popup, in that for example input i got this values from local storage of popup window.
In manifest i added permission for "storage"
From popup i tried this:
function updateStorage(data, callback){
if(data){
for (const [key, value] of Object.entries(data)) {
chrome.storage.local.set({ key: value }, callback);
}
}
return false;
}
function getFromStorage(storageElement, callback){
if(storageElement){
return chrome.storage.local.get(storageElement, callback);
}
return false;
}
Then in later code, i try to get getFromStorage('myItem', result => {console.log(result)})
Writing i make like this:
updateStorage({'myItem': 'almost secret data'}, _ => {console.log('test')})
But when i check the popup application then local storage, there is nothing. When i reload page or re click on extension, i can't see the local storage item that i was write like 10s ago.