我正在使用以下数据在 Node 上访问 Web 服务,
我的请求数据是:
{
"first_name":"surinder",,
"last_name":"rawat",
"email":"surinder.rawat@testcompany.com",
"phone":"1234567890",
"password":"surinder",
"user_type":"H",
"device_type":"A"
}
并得到以下错误:
Connect
400 SyntaxError: Unexpected token ,
at Object.parse (native)
at parse (/home/surinder/workspace/HappyHakka/node_modules/body-parser/lib/typs
/json.js:76:17)
at /home/surinder/workspace/HappyHakka/node_modules/body-parser/lib/read.js:98:18
at IncomingMessage.onEnd (/home/surinder/workspace/HappyHakka/node_modules/body-parser
/node_modules/raw-body/index.js:136:7)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.emit (events.js:92:17)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
我故意使用双逗号来得到这个错误。我想知道如何处理此错误并以正确的格式向用户显示错误
谢谢