'how to manage [object HTMLDivElement] and get its content?
I have saved an array in local storage and trying to use it but when I console.log the localstorage.getitem it returns [object HTMLDivElement] I have tried to use .innerhtml or [...] on it but they didn't work. Btw, since it's an array, I have to use JSON.stringify(movieWatchlistArray):
localStorage.setItem("key",JSON.stringify(movieWatchlistArray))
let str =localStorage.getItem("key")
console.log(JSON.parse(str) )
But when I do this, it will return an empty object inside an array while when I console.log the original array it's fine so I tried to do it without JSON part, it worked but returns a string of [object HTMLDivElement]
localStorage.setItem("key",movieWatchlistArray)
let str =localStorage.getItem("key")
console.log(str)
So how to get the content of [object HTMLDivElement] I have used .innerhtml but it says can't use .innerHTML on undefined .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
