# Browser.storage.sync/local.get/set not working

**URL:** <https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565>\
**Category:** Development\
**Created:** [March 9, 2020, 5:53pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565 "2020-03-09T17:53:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Utkarsh\_Singh](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@Utkarsh\_Singh](https://discourse.mozilla.org/u/Utkarsh_Singh)\
**Post date:** [March 9, 2020, 5:53pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565/1 "2020-03-09T17:53:09Z")

</div>

I am building a simple extension that needs to save some basic data. However, the browser.storage is not working at all. Here is my code:

> browser.storage.local.set({kitten: { name: “Mog”, eats: “mice” }})  
> .then(() =\> {  
> browser.storage.local.get([“kitten”])  
> .then(results =\> console.log(results))  
> }).catch(e =\> console.error(e))

It just prints this:

Am I using the functions wrong? How exactly can I save this data locally which can be used later?

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [March 9, 2020, 6:01pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565/3 "2020-03-09T18:01:25Z")

</div>

Seems fine to me:

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/7/a/7a2794f253cc10bb1b2e42a6fcc0b945af7a6f0a.png)

Where are you testing this?

---

<div class="post-metadata">

**Author:** ![Utkarsh\_Singh](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@Utkarsh\_Singh](https://discourse.mozilla.org/u/Utkarsh_Singh)\
**Post date:** [March 9, 2020, 6:05pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565/4 "2020-03-09T18:05:06Z")

</div>

I am testing for the console logs in the Browser Toolbox. Also, ‘browser’ is not defined when I try running it in the Browser Toolbox too.  
 ![Screenshot from 2020-03-09 23-33-36](https://us1.discourse-cdn.com/flex001/uploads/mozilla/optimized/3X/9/8/98133acae7435ebc0dcc59f944fd4e4f7d7d7d14_2_690x14.png)

I just checked in the Developers Toolbox Storage. It seems that the items are getting stored after all. But for some reason, I can’t seem to access it.

 ![Screenshot from 2020-03-09 23-38-19](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/3/5/35225b33c7e7dba29ddb22fd5d2105f936dbd952.png)  
What are the reasons this is not working for me? I have added the addon ID too: “gecko”: {  
“id”: “{ec8030f7-c20a-464f-9b0e-13a3a9e97384}”,  
“strict\_min\_version”: “42.0”  
}

---

<div class="post-metadata">

**Author:** ![Utkarsh\_Singh](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@Utkarsh\_Singh](https://discourse.mozilla.org/u/Utkarsh_Singh)\
**Post date:** [March 9, 2020, 7:41pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565/5 "2020-03-09T19:41:37Z")

</div>

Thanks.  
I solved the issue. It seems that the value was getting saved always.  
I just couldn’t see the items getting saved in the seperate Browser Toolbox window where I was trying to console.log() the item. Why? I still don’t know.  
But then I clicked on ‘Inspect’ for my extension in the “about:debugging” page, and there, I ran the following code just as you did. It worked, and I could also see the keys and values under Storage.  
This is probably a glitch in the Browser Toolbox Window, and anyone facing this problem should try debugging like @freaktechnik

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [March 9, 2020, 7:45pm UTC](https://discourse.mozilla.org/t/browser-storage-sync-local-get-set-not-working/55565/6 "2020-03-09T19:45:15Z")

</div>

> [@Utkarsh\_Singh](#):
>
> I just couldn’t see the items getting saved in the seperate Browser Toolbox window where I was trying to console.log() the item. Why? I still don’t know.

The normal browser toolbox runs in a browser context, not an extension context. That’s why it worked fine when you used the debugger for the extension.
