Cannot convert object to primitive value

如下是我的提交数据(json):

{
"form_1":[{"resultName":"","level":"","unitOrder":"","winner":"","winnerOrder":"","date":"1","score":""}],"form_2":[{"resultName":"","level":"","unitOrder":"","winner":"","winnerOrder":"","date":"1","score":""}],"form_3":[{"resultName":"","level":"","unitOrder":"","winner":"","winnerOrder":"","date":"1","score":""}]
}

然后express下获取req.body打印:

console.log(req.body)

报错:

TypeError: Cannot convert object to primitive value

请问这种情况怎么回事呢?我要如何正确获取传过来的数据

阅读 10.2k
2 个回答

数据类型转换不成功 提交数据应该是集合类型,外面的"form_1",不能找到对应的字段,后面还有"form_2"。。这个的,建议去掉,直接{1:{},2:{},3:{}},这样提交

你直接把对象提交了?没有JSON.stringify()?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏