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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -