简体   繁体   中英

how to update localstorage value?

Here is the origin json set in the local storage

"profiles": [
    "headers":[
        "key": "val"
        "value": false
    ]
]

And I've got the value of the header which is false from the console by the following code

chrome.storage.local.get(['profiles'], function(p){console.log(p['profiles'][0]['headers'][0]['value'])})

Now I would like to update the header's value to true in this case

I've tried both modified the value from get() callback and use the chrome.storage.local.set() But none of them are working.

Any suggestions how to do it?

Use

localStorage.setItem('key','value')

to update local storage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM