Learn localStorage by Building a Todo App - Browser Testing

While I was coding along, I used Visual Studio Code and FireFox to test every step and it worked fine.
When I reached the steps of adding JSON code, I stopped testing and just used the freeCodeCamp website to finish the remaining steps.
So I was surprised when I tested the finished code with Visual Studio Code and FireFox and everything stopped working.
But when I tested the App in Chrome, it worked normally.

Just wondering why the finished app works fine in Chrome while in FireFox nothing works and it shows the following error:

Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data

FireFox was used while completing the freeCodeCamp course and the final app did work in the freeCodeCamp website but not when I used Visual Studio Code to open the app on FireFox.

I even copy and past the original code from the course into Visual Studio Code (in case of typo) but it still didn’t work


Without seeing what that unexpected character is, it will be hard to find the reason.

It can be a simple extra dot in a file name, which points to a hidden folder, and Firefox might not be checking for hidden folders.

Hi Daniel,

Thanks for the reply,
I think I might have found the problem.

The local storage of FireFox seems to show “data” as objects and not strings.

As this is the code I’ve copied from the course, and
the App seems to work fine on Chrome and Edge, and
I’ve googled the problem and it seems there are other people who have encountered bugs while using JSON.stringify() with FireFox,
so I can only assume that the way JSON.stringify() is used in this course works in Chrome and Edge but not FireFox

Maybe there’s a different way to write the code or an alternative to using JSON.stringify() .

I’ll give an update when I do find a solution.

I just published the App in Github and it works on FireFox!
No errors!
I guess the problem only occurs when I use Visual Studio Code to preview the App in FireFox.