Local storage issue
View other answers to this thread3.4K+ developers have started their personal blogs on Hashnode in the last one month.
Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more
CS Student | Software Developer
In the following line:
localStorage.setItem('notes', JSON.stringify(nextNotes));
where does the value for nextNotes
come from? When you call the addItem
function, you do not pass any argument for nextNotes
.
You push the new note to the notes
array but you store nextNotes
in the local storage afterwards.
Don't you mean:
localStorage.setItem('notes', JSON.stringify(notes));
I had a look on your code on GitHub. The problem is your localStorage.setItem
and localStorage.getItem
method.
From local-storage.js
you export an object with a get
, set
and remove
method. So when you call localStorage.setItem
or localStorage.getItem
in your file above, there are no function with these names.
You have to call localStorage.set
and localStorage.get
.
But there are also othere bugs you will get when you fix this one.