I have an array of objects on a page that I want to have on another page in electron. Both pages have there own javascript file and there is one function.js file.
file1.js
const { createArray, getArray } = require ('./function')
window.onload = () => {
createArray()
sessionStorage.setItem("Array", getArray)
console.log(sessionStorage.getItem("Array") //[object Object],[object Object],[object Object]
console.log(getArray) // [{"1": 10}, {"2": 11}, {"3": 12}]
}
By the documentation of Electron getting variables from one page to the other is best done via the HTML 5 API's.
But I'm not able to store an array of object in a sessionStorage. According to this post that is perfectly normale. The solution used here is to stringify. But that is a rather expensive process that I would like to avoid.
Does anybody have any idea how best to share an array of objects between two pages?