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
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() .
Update:
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.