Error during parsing of an object by JSON.parse()

Tell us what’s happening:
After the successful execution of Model.remove() function upon matching a certain criteria, the response which is obtained is not being parsed properly and is throwing a hard-stop error, like so: SyntaxError: Unexpected token o in JSON at position 1
Stack trace points towards the server.js file where JSON.parse is written. Looking that up in various places shows that this issue usually happens when the response is already an object and JSON.parse() (which is expecting a string) tries to parse this response object.
Should this be handled in the handler code or in the server.js code? Please clarify.

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 Edg/97.0.1072.69

Challenge: Delete Many Documents with model.remove()

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.