Reputation: 105
I set an item in localstorage in this way:
localStorage.setItem("test", "testing");
Now, I try to remove it but it's not working. I found and tried the following solutions without any result:
localStorage.removeItem("test");
localStorage.removeItem(0);
window.localStorage.removeItem(0);
window.localStorage.removeItem("test");
Is there another way to do it?
Upvotes: 1
Views: 6067
Reputation: 75
Your problem may be caused by your local hosting
this problem happened to me and I always thought that the problem was from my code, but later it became clear to me that the problem is from the local hosting
I used this address in my project:
http://192.168.1.10:8080
And then I replaced the address with this:
http://127.0.0.1:8080
The problem is solved and now I can delete all LocalStorage from the inspect.
Upvotes: 0
Reputation: 105
I found the problem. It wasn't local storage, it was due to the order of executions of my functions. In my first function, I set the local storage variable. In the second one, I use it and remove it. The problem was that the second function was executed faster than the first one. So the data was deleted and then, set again. That gave me the impression that local storage deletion wasn't working.
Upvotes: 6