Trouble with posting JSON data (with node request) to Express server for saving into MongoDB

时光怂恿深爱的人放手 提交于 2019-12-02 10:05:25

Issue is with form: JSON.stringify(class) in your first request. form takes url encoded form input, stringified json won't work. check content-type header (application/x-www-form-urlencoded)

json: class in your 2nd snippet works as this handles json data and sets correct content type header correctly.

Try .toJSON() method over class before sending.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!