I have that problem: I’m trying to reach the property of on object “user” that I save in localStorage and the browser gives me the error “Cannot read properties of undefined”.
I apply my code
like(recipe) {
if (this.favorites.indexOf(recipe) === -1) {
this.favorites.push(recipe)
}
let user = JSON.parse(localStorage.getItem("users"));
let currFav = user.favorites;
currFav.push(recipe);
localStorage.setItem("users", JSON.stringify(user))
}