JSON - a love story
Scene: adding a PUT route with a bodyParser.json()
as middleware.
- Creates request in Postman as application/json
GetSyntaxError: Unexpected token "\n
-
Uncertain, tries a few other things (removing middleware, using
debugger
statements, …) - Those being unsuccessul, decides to validate request body
- Gets:
Error:Strings should be wrapped in double quotes.[Code 17, Structure 2]
:%/s/\'/\"/g
- …
- PUT route now works!
TIL: json expects "
and not '