At some point, something you did corrupted the value of your LocalStorage for that key. LocalStorage can only store strings, so if you pass anything else to it, it will convert it to a string. Since your value is 'undefined'
, that means that at some point, you probably did something like this on accident:
var value;
localStorage.setItem('key', value);
In this case, value
is undefined
, which is not a string. When this gets saved, it will be converted however. Unfortunately, "undefined"
is not valid JSON. That means that when it tries to parse, it will throw an exception.
To fix your issue, you should clear the bad value out with removeItem
.
localStorage.removeItem("customerDatabase");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…