I am making a Chrome extension where I will store the password from the user in local storage. I am storing it in popup.js using
chrome.storage.local["mykey"] = "xxx";
When I use chrome.storage.local["mykey"], I'm getting undefined. Can you tell me how to store and retrieve user data in a Chrome extension?
According to the chrome.storage API, the correct way to store a value is with .set:
chrome.storage.local.set({"mykey": someData}, optionalCompletionCallback);
And to access the value later, use .get with a callback that accepts the data:
chrome.storage.local.get("mykey", function(fetchedData) {
alert("fetched: " + fetchedData.mykey);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With