从 bodyParser 中无法识别

Getting unidentified from bodyParser

我刚刚开始学习 nodejs + express + handlebars,我的 post 遇到了困难。这是我收到的请求正文,我似乎无法使用 req.body.province 和 req.body.municipality 获取 "province and municipality" 数据,但有了轴承,我可以。

{
'province ': 'ALBAY',
  'municipality ': 'BACACAY',
  bearing: '>=1 and <=20'
}

这就是我从市和省的表格中获取数据的方式。

<div class="form-group">
<label for='municipality'>Municipality</label> <select type= "text" name="municipality " class="form-control"> {{#each municipality}}
 <option>{{municipality}}</option> 
{{/each}} </select>

这是轴承。

<div class="form-group">
<label for="bearing">Bearing Trees</label> <select type="text" name="bearing" class="form-control">
 <option>>=1 and <=20</option>
<option>>=21 and <=50</option>
<option>>=51 and <=100</option> <option>>100</option> </select> </div>

我现在有点卡住了,我需要你的帮助。谢谢

据我所见,市和省对应的键最后包含一个space。

在一个对象中,所有键都是字符串类型,这意味着 space 包含在内,除非您使用符号。

对于你的问题,这是一个错别字。

您的对象应如下所示:

{
    province: 'ALBAY',
    municipality: 'BACACAY',
    bearing: '>=1 and <=20'
}