javascript - 在node.js中通过post方法发送数组数据,如何在控制台上打印我试过这个
问题描述
详细信息:如何仅在通过 post 方法在服务器上发送的数组的控制台上打印特定值
router.post('/', function(req, res, next) {
var mj = new Array();
mj = req.body.equip;
console.log("this" + req.body.equip[]);
console.log(mj);
});
我用了这个,但它没有给出结果
<input type="text" name="equip[]">
<input type="text" name="equip[]">
<input type="text" name="equip[]">
解决方案
我认为下面的代码将帮助您打印每个值。
var array=req.body.equip;
array.forEach(function(element) {
console.log(element);
}, this);
推荐阅读
- reactjs - 十几个 mobx 注入功能会影响性能吗?
- java - GRPC 通过 TOR 连接
- python - 为什么自定义平均过滤器(3x3)的输出与opencv的平均过滤器不同?
- google-cloud-platform - GCP 对存储桶 (GCS) 的只写访问
- python - WebElement Object.text 返回无法剥离的特定字符串
- javascript - 如何通过数组中的特定对象值进行搜索并仅返回在 mongoDB 中搜索到的对象
- docker - C++ setlocale() 返回“NULL”
- algorithm - 合并 k 个排序列表:空间复杂度
- wix - 如何在升级时跳过 InstallDir 对话框
- python - 从单独的函数检查 python 线程的状态