I have a simple, working chrome extension that sets and gets values on chrome.storage
.
I am not able to retrieve the key-value pair I set manually (by manually, I meant through chrome developer tool). I have tried typing on dev tool console
chrome.storage.sync.get(null, function(items) {
var allKeys = Object.keys(items);
console.log(allKeys);
});
returns
`Uncaught TypeError: Cannot read property 'sync' of undefined
at <anonymous>:1:16`
I tried different varieties on chrome devtool console, but it seems like on console chrome.storage
always returns undefined.
This is what the app does. It is a simple text area that sets and gets a predefined key value.
popup.html
<textarea rows="10" cols="15" id="texti"></textarea>
<button id="buttoni">Sat value</button>
<button id="button_geti">Get value</button>
<script src="popup.js" ></script>
popup.js
const texti = document.getElementById("texti")
const buttoni = document.getElementById("buttoni")
const button_geti = document.getElementById("button_geti")
buttoni.addEventListener("click", () => {
chrome.storage.sync.set({"awesomeKey": texti.value}, function() {
alert('Value is set to ' + texti.value);
});
})
button_geti.addEventListener("click", () => {
chrome.storage.sync.get(["awesomeKey"], (result) => {
alert("Key is " + result.awesomeKey)
})
})
Again, the above works, but I can't figure out a way to "pry" into my key-values manually.
I also checked Application
tab but it has nothing. I don't see any awesomeKey
key defined anywhere.
How can I access/ debug chrome.storage
on devtools?