title: How to store data that persists after close using an extension in Firefox
body: <p>I am writing a Firefox extension using WebExtension which stores data of the tabs open in a window and saves it for later use. It is similar to a feature in MS Edge. 
  To store persisting data I am using storage.local API
  However as I am testing whether the storage and retrieval of data is working, I am having trouble retrieving the data. I should also probably mention that I am new to Promises.</p>
  
  <p>I have an object dataToStore{id,tabs[],numOfTabs,tags} which I send to be stored using <code>browser.storage.local.set(dataToStore);</code></p>
  
  <p>Then I have an object dataRetrieved{} which is used to store the return of <code>browser.storage.local.get(null)</code> which returns a Promise</p>
  
  <p>Here is the code:</p>
  
  <pre><code>
  //At this state dataToStore has the necessary data inserted in it
  console.log(dataToStore);
  browser.storage.local.set(dataToStore);
  let dataRetrieved={};
  dataRetrieved = browser.storage.local.get(null).then(() =&gt; {
     console.log(dataRetrieved);
  });
  
  </code></pre>
  
  <p>The output of <code>console.log(dataToStore);</code> is:</p>
  
  <pre><code>Object { id: 1563507620695, tabs: (3) […], numOfTabs: 3, tags: null }
  </code></pre>
  
  <p>which is as expected.
  However the output of <code>console.log(dataRetrieved);</code> is:</p>
  
  <pre><code>Promise { &lt;state&gt;: "pending" }
  </code></pre>
  
  <p>I was expecting both the outputs to be same. As far as I know, the lines within .then is supposed to run only after the promise has returned value. However this does not seem to be the case here.
  How do I access the stored value?</p>
  
  <p>Reference:
  <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea" rel="nofollow noreferrer">MDN for storage</a></p>
  
  <p><a href="https://github.com/mdn/webextensions-examples/blob/master/annotate-page/sidebar/panel.js" rel="nofollow noreferrer">Example of it from MDN Github</a> lines 19,33</p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get" rel="nofollow noreferrer">MDN for StorageArea.get()</a></p>