Welcome again. I have a problem with POST route. My question is: is it possible to get data as an array from li tag in req.body?
HTML code:
<form class="form" action="/creator" method="POST">
<div class="selected-users">
<h3>Added Users:</h3>
<ul class="selected-users-list" name="players">
</ul>
</div>
</form>
<div class="container2">
<div class="tournament-users">
<h3>Users to add</h3>
<div class="alert-user-selected"></div>
<div class="select-box">
<div class="options-container">
<% for ( let user of users ) { %>
<div class="option">
<input type="radio" class="radio" name="user">
<label class="user-login" for="<%= user.login %>" id="<%= user._id %>"><%= user.login %></label>
</div>
<% } %>
</div>
<div class="selected">
<input class="find-user" type="text" placeholder="Select User">
</div>
</div>
</div>
</div>
In JS code I am putting in tag ul
my selected users as li
tag.
In my POST route when I console.log(req.body)
I cant't see my picked players/users despite the fact that my players are added on my page when I pick them, but they don't exists in req.body.
My final question is: How to past them to req.body as array or Object.
Thanks and Best regards.
Karollo.
You need to pass the user into the HTML as follows If you want to get them from the request body:
<input type="radio" class="radio" name="user[]">