So I started learning NodeJS for a personal project. I have a simple endpoint:router.post("/comment"), (req,res) => { // whatever }) Here I expect req.body.comment and I run basic validation (like length, type, etc) but if I send something like this{ @#$$XXX: "whatever" } the app spits something like that: "SyntaxError: Unexpected token i in JSON at position X"When I send such malformed request I don't even think it hits the actual endpoint and dies off somewhere else. Should I be handling it somehow? I am running an instance of the app on Heroku and it actually tells me "In the last 24 hours, there have been X critical errors for this app". Kind of scary stuff.
Submitted June 02, 2019 at 09:35PM by pink_tshirt
No comments:
Post a Comment