简体   繁体   English

无法在基于 Node ExpressJS 服务器的服务器发送事件中检索 req.body 的值?

[英]Cannot retrieve value of req.body in server-sent events based Node ExpressJS Server?

I am trying to send payload from sse client to sse node server.我正在尝试将有效负载从 sse 客户端发送到 sse 节点服务器。 I'm receiving sse.js on React client to send payload back to server but getting JSON error我在 React 客户端上接收 sse.js 以将有效负载发送回服务器,但收到 JSON 错误

SyntaxError: Unexpected token " in JSON at position 0 at JSON.parse () at createStrictSyntaxError (/home/salman/Desktop/my-sse-js/server/node_modules/body-parser/lib/types/json.js:158:10) SyntaxError: Unexpected token " in JSON at position 0 at JSON.parse () at createStrictSyntaxError (/home/salman/Desktop/my-sse-js/server/node_modules/body-parser/lib/types/json.js:158: 10)

React Client Node Express.js Server React 客户端节点 Express.js 服务器

The json file seems to have some errors, which is why JSON.parse() fails. json 文件似乎有一些错误,这就是 JSON.parse() 失败的原因。 Check it in a JSON Validator like https://jsonlint.com/ or https://jsonformatter.curiousconcept.com/在 JSON 验证器中检查它,例如https://jsonlint.com/https://jsonformatter.curiousconcept.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM