Hi all
I created an example script to Save and Load data from the Storage Area.
I wrote the following code to save a simple String to the Storage Area:
var FileName="12345.gif";
browser.storage.local.set(FileName);
As can be seen, my object is not a JSON Packet, but just a simple String.
From what I understood so far, my code above saves a Key-Value pair,
in which the **Name** is "FileName" (like the Variable's Name), and the **Value** is "12345.gif".
I now want to read it back, so I wrote this code:
browser.storage.local.get("FileName").then
(
(FileName) => { console.log("FileName="+FileName); }
);
When I run it, my Debug window shows:
> FileName=[object Object]
It seems that I did get an Object back, and not null.
But what do I need to change, to get to the actual **Value** of the Object that I got?
Thank you
Your `set` code is wrong. It takes an object, not a string. Try this.
var FileName=”12345.gif”;
browser.storage.local.set({FileName: FileName});
OR
var FileName=”12345.gif”;
browser.storage.local.set({FileName});