Slev7n
Slev7n

Reputation: 371

How to get data from chrome extension local storage?

I'm developing a chrome extension, popup.html saves some data into extension's local storage (key:viewMode value:WYSIWYG)

When I'm trying to retrieve the data using Chrome Storage API from script.js, it says that viewMode is undefined.

Here is manifest.json

{
    "manifest_version": 2,

    "name": "LoremIpsum",
    "description": "Dolor sit amet",
    "version": "1.2.8",

    "permissions": [
        "http://*.exemple.org/*",
        "storage"
    ],

  "browser_action": {
    "default_icon": {
      "19": "icons/19.png"
    },
    "default_title": "LoremIpsum",
    "default_popup": "popup.html"

    "icons": {
        "16": "icons/16.png",
        "19": "icons/19.png",
        "48": "icons/48.png",
        "128": "icons/128.png"
   },

   "web_accessible_resources": [
    "img/*.png",
    "smilies/*.gif",
    "style.css"
  ],

    "content_scripts": [
        {
            "matches": ["http://*.exemple.org/*showtopic*", "http://*.exemple.org/*act=ST*"],
            "css": ["style.css"],
            "js": ["jquery-1.10.2.min.js", "popup.js", "script.js"] 
        }
    ]
}

Upvotes: 2

Views: 2772

Answers (1)

Slev7n
Slev7n

Reputation: 371

I just realized that I made a dumb error while setting chrome.storage.local. I've passed arguments as an array instead of passing them as an object.

Upvotes: 1

Related Questions