DEV Community

Discussion on: Beginner Node Help- take 2

 
dmfay profile image
Dian Fay

req.body is a hash, not an array. You can't iterate it, but you shouldn't need to. If you want the scores for the fifth hole, for example, that's req.body.PAR5 based on how you've named your input elements. That is an array since you have multiple inputs named PAR5, so Mike's score should be req.body.PAR5[0].

Thread Thread
 
masmithrpg profile image
masmithrpg

I was close.

The example i came across,showed req.body[0].PAR5

thanks for the help.

Thread Thread
 
masmithrpg profile image
masmithrpg

Unfortunately, i don't find much time to work on this, but today i got back to it and found a problem. I don't know if it is an issue i have to deal with because of HTML or because of body.parser.
I have a golf course named 'Highland Park'
i pass the course in as result in my .pug file and it displays properly.
I then have a hidden field in my body for the course name

td: b <input type="hidden" name = "COURSE" value= #{result}
when i process my hash, course shows as 'Highland'
it doesn't appear to be a size issue, but something to do with the space.

If i change the course name to 'HighlandPark', my hash shows 'HighlandPark'

Hope that makes sense.

Any idea how to handle this?