ParagDineshGupta
ParagDineshGupta

Reputation: 224

array data send by post method in node.js,how to print on console i tried this

detail:how to print a specific value only on the console of the array which is send on server by post method

router.post('/', function(req, res, next) {
    var mj = new Array();
    mj = req.body.equip;
    console.log("this" + req.body.equip[]);
    console.log(mj);
});

i used this but it is not giving result

 <input type="text" name="equip[]">
 <input type="text" name="equip[]">
 <input type="text" name="equip[]">

Upvotes: 0

Views: 309

Answers (1)

vijesh
vijesh

Reputation: 1173

I think below code will help you to print each values.

var array=req.body.equip;
array.forEach(function(element) {
    console.log(element);
}, this);

Upvotes: 2

Related Questions