Once I submit the value "Tokyo" selected in the form, the value which receives at node.js includes unnecessary character "\u001c" before "Tokyo".
Right Value : "Tokyo"
Wrong Value : "\u001cTokyo"
I would like to save the right value in Monogodb.
As a tentative solution, I tried to delete the only unnecessary characters and save the value in mongodb, but it didn't work.
req.body.prefecture.replace(/\u001c/g, "");
To make sure what is happening, I have dumped the value which received at node.js from html.
Front End : Html
<form action="/places/update" method="post" enctype="multipart/form-data">
<select class="form-control" id="prefecture" name="prefecture">
<option value="Tokyo" selected>Tokyo</option>
<option value="Chiba">Chiba</option>
<option value="Kanagawa">Kanagawa</option>
</select>
<button type="submit" class="btn btn-success">Register</button>
</form>
Back End : node.js
router.post("/update", upload.single("file"), (req, res) => {
console.log(req.body);
console.log(req.body.prefecture);
console.log("Tokyo");
});
Log
[Object: null prototype] {
prefecture: '\u001cTokyo'
}
Tokyo
Tokyo
Could you let me know why this happen and how to get correct value?