投稿フォームから来ているreqの処理に問題があります。基本フォームからの処理依頼
フォームは私が何であるかを確認するときvirable
router.post('/', jsonParser, function(req, res, next){
var test = req.body;
var test0 = test.map-city;
var test1 = test.map-symbol;
});
に各値を保存しようという
<form action="/" method="POST">
<div class="form-group">
<label for="city-input">City name</label>
<div class="col-10">
<input class="form-control" type="text" id="city-input" name="map-city">
</div>
<input type="checkbox" aria-label="..."/>
<label style="color: #737373;font-family: 'Open Sans', sans-serif;line-height: 30px;">Choose or type</label>
</div>
<div class="form-group">
<label for="example-text-input">Symbol</label>
<div class="col-10">
<input class="form-control" type="text" id="example-text-input" name="map-symbol">
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
のように見えることは、私は
Object{map-city: "downtown", map-symbol: "dt"}
方法を得るreq.bodyですこれを処理して各プロパティを文字列に保存する
今、私はエラーが出る - にReferenceError:都市は
は、あなたがそれにハイフンでオブジェクトのプロパティにアクセスしようとした場合はJavaScriptはエラーがスローされますので、ドット表記を使用して
Youre doing test.map *マイナス*市。あなたはテストをしたい["map-city"] –