Tuesday, 18 April 2017

Input array field adding single quotes when console log in express js (node js)

I have a form with some input field and also have a array input field :

<input type="hidden" id="user_id" name="user_id" value="1" />
<input type="text" name="test[0][name]" value="car" />
<input type="text" name="test[1][value]" value="100" />

I am posting this form via ajax. Now when I console log post data into express js. I am getting like below :

{
 user_id : '1',
'test[0]' : 'a',
'test[1]' : 'b',
}

Now I am able to access user_id using post.user_id but can not access test array.

I am trying to access test array using post.test and post.test.name but getting undefined always,

So can anyone help me out ? Thanks in advance



via Ankit

No comments:

Post a Comment