javascript - 作为 [object Object] 进入服务器的对象数组
问题描述
我正在尝试将当前状态的属性作为(对象数组)发送到我的服务器。当我尝试将它记录到我的服务器中时,它作为 [object Object] 的数组返回。JSON.stringify 仅在每个对象周围添加“”。
//sending my current players property to here
getFantasyPros: function(players) {
return axios.get("/api/scraper/" + players);
},
//end point
router.get("/:players", (req, res) => {
const playerArr = JSON.stringify(req.params);
console.log(playerArr);
}
解决方案
您需要通过您的回复(res)返回一些东西。添加到端点的末尾。
return res.json({
playerArr,
msg: 'It worked'
})
推荐阅读
- php - 从 Firebase 存储 (PHP) 获取 URL
- windbg - 将 Windbg 限制扩展到 1MB 以上?
- flutter - Flutter.dev SharedPreferences 问题
- reactjs - React redux 在异步 API 中跟踪状态
- javascript - 通过 HTTP 服务器下载链接
- node.js - 使用 Cosmos DB Core SQL API 嵌套 JS 和嵌套 JSON
- sharepoint-online - SharePoint online 显示或隐藏具有相同功能所需的多个字段的列
- matlab - 如何像在 Matlab 中手绘一样连接数据点
- wpf - 区域更改时 wpf 中的日期时间没有更改
- mule - 如何调试自定义 mule 4 SDK 连接器?