1

I'm trying to update my chrome apps to have some new manifest features but I have to rewrite some of code to do so. Here are examples of local storage get item that I believe I need to use either chrome.local.storage or sync.

        var name = 'chrome-writer-files';
        document.forms.editor.doc1.value = localStorage.getItem(name);

        var name = 'chrome-writer-files2';
        document.forms.editor.doc2.value = localStorage.getItem(name);

        var name = 'chrome-writer-files3';

        document.forms.editor.doc3.value = localStorage.getItem(name);

Please let me know how I can rewrite this so I don't get the error.

Justin
  • 26,443
  • 16
  • 111
  • 128
Blynn
  • 1,411
  • 7
  • 27
  • 48

1 Answers1

3

You need to use chrome.storage.local.get() instead.

Learn more: https://developer.chrome.com/extensions/storage.html#method-StorageArea-get

Full example: (Chrome - chrome.storage.local.get and set)

chrome.storage.local.set({'someItem': 'some value'});

chrome.storage.local.get('someItem', function (result) {
    alert(result);     
});
Community
  • 1
  • 1
Justin
  • 26,443
  • 16
  • 111
  • 128
  • I know I've been going through that it just doesn't make much sense. I tried this too. var name = 'chrome-writer-files'; document.forms.editor.doc1.value = chrome.storageArea.get(name); – Blynn Apr 16 '13 at 21:23
  • Thanks that is a valid way I'll try to rewrite my function now. – Blynn Apr 16 '13 at 21:31