我正在尝试发布一个序列号数组,但是一旦它被发布,所有添加到文本区域中的序列号都会作为单个字符串一起发布。
这是我的表格:
<form class="" id="serialsForm" action="/serialsnew" method="post">
<h5 style="text-align:center">Procesar RMA</h5>
<input placeholder="Product ID"class="input1" type="text"
name="productId" value="">
<textarea id="textAreaSerial" class="newSeriales" placeholder="#
Seriales"name="serial[]" rows="3" cols="80" ng-trim="false"> .
</textarea>
<button type="submit" value="send" class="btn btn-primary
buttonNewRma" data-toggle="modal" id="submit">
submit
</button>
</form>这是我的post请求
app.post("/serialsnew", function(req, res){
var productId = req.body.productId;
var serialNum = req.body.serial;
Seriales.create({
product: productId,
seriales: serialNum,
}, function(err, serial){
if(err){
console.log("we coulndt add the serial numbers")
} else{
console.log("we just added a patch of serials")
}
})
res.json(req.body);
// res.redirect("/serialsnew")
})这是我的数组在res.json上的外观
我正在尝试创建序列号的输入,这样我们就可以跟踪保修时间。下面是我想要如何存储数据的一个示例。
{
productId: "laptops",
serial: [
11111,
22222,
44444,
]}
https://stackoverflow.com/questions/51794917
复制相似问题