I searched everywhere to find the solution, but I find none of them are relevant to mine.
I tried to store a variable in local storage, but I'm getting the below error:
raise MakeError('TypeError',
JsException: TypeError: Undefined and null dont have properties (tried getting property 'setItem')
So I checked whether it is running on browser,
if (typeof window !== 'undefined') {
console.log('You are on the browser')
if(message1!='undefined'){
console.log("message1 is not undefined")
window.localStorage.setItem("vOneLocalStorage",message1);
}
}
Before giving the error, it printed "You are in the browser" in console, which I gave in the code to test
output in console before giving the error
I don't understand what is the cause, and why is it not able to store the variable in the local storage.
The tech stack I use are Javascript, React, python, and Js2py library to pass input from Python to Javascript.