javascript - Using a variable in req.body -
how use variable in req.body
example:
var names = {abc,xyz,cde}; var check = req.body.names[0];
or
var names = {abc,xyz,cde}; var dummy = names[0]; var check = req.body.[dummy];
the first case throws error cannot read index 0
, second gives error of unexpected token '['
. trying fetch form data who's names stored in array names.
ps: using node in end.
if use numeric indexes names
must array. use bracket notation:
var names = [abc, xyz, cde]; var check = req.body[names[0]];
Comments
Post a Comment