'How do I update a certain value in LocalStorage inside a nested object?
I set it like this:
chrome.storage.local.set({
myState: {
data: {
website: "google.com",
visited: false,
count: 0
}
}
})
If I want to change myState.data.visited to true, what should I do?
Solution 1:[1]
You need to get the data, change it and save it again.
chrome.storage.local.get('storageKey', function(result) {
//data.visited will be in the result object for a specific key. You can change data.visited
//to be true here. After changing it to true you can save it again under
//the key 'storageKey' or any key you like.
chrome.storage.local.set({storageKey: result});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jakobinn |
