-
Notifications
You must be signed in to change notification settings - Fork 1
JSON.parse can be dangerous #84
Copy link
Copy link
Open
Description
https://github.com/fac-12/BudgetPlanner/blob/master/public/index.js#L22
If the xhr.responseText is a string here, JSON.parse will fail with Uncaught SyntaxError: Unexpected token a in JSON at position 0, which will break things.
So its good to 'wrap' JSON.parse in a try/catch block, see below for an example:
https://stackoverflow.com/questions/29797946/handling-bad-json-parse-in-node-safely
PS. please share this with the whole cohort as its something thats valuable to know
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels