Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get inner object from a nested object in chrome app storage [duplicate]

i have an object stored inside chrome storage 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 that seems not to work Error in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices.

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

ant ideas?

like image 830
Patrioticcow Avatar asked Mar 09 '15 22:03

Patrioticcow


1 Answers

You can't do that in a single API call. The API only gives access to top-level keys: you can get or set planA as a whole.

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

like image 116
Xan Avatar answered Oct 11 '22 18:10

Xan