How to delete data from an object using chrome memory?

I have an object stored inside a chrome store that looks like this:

{ "planA": { 123: {key: 'some key'} 124: {key: 'some other key'} }, "planB": { 223: {key: 'some key'} 234: {key: 'some other key'} } } 

I want to do something like chrome.storage.sync.remove([{"planA": "123"}]);

but this does not work Error in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices.

from documentation StorageArea.remove(string or array of string keys, function callback)

ant ideas?

+4
source share
1 answer

You cannot do this in a single API call. The API provides only access to the top-level keys: you can get or install planA as a whole.

So, you need to write your own get / set functions that retrieve the required top-level key, modify the object as needed, and save it.

+5
source

Source: https://habr.com/ru/post/989933/


All Articles