I am setting a map data type in local storage. But when i retrieve it, I am not able to access the data in the map.
let campaignToEmails = {};
let campaignToViews = {};
// Add some data into the above two maps.
console.log(campaignToViews); //Shows the data correctly
console.log(campaignToEmails); // Shows the data correctly
local.setItem(“campaignToEmails”, campaignToEmails);
local.setItem(“campaignToViews”, campaignToViews);
The log shows the map of campaign id to views count correctly.
However, in a different function, I do this :
let campaignToEmails = local.getItem(“campaignToEmails”);
let campaignToViews = local.getItem(“campaignToViews”);
console.log(campaignToViews); //Only prints out object Object.
console.log(campaignToEmails); //Only prints out object Object.
I can’t access the data in the map anymore.
The log here just shows object and i can’t get the views with campaign id anymore. Seems like we are not able to cast the map back.
Any help on this please ?