I am trying to read the input from an HTML form and use it in Node.js.
This is my HTML form:
<form action="/myform" method="POST">
<input type="text" name="mytext" required />
<input type="submit" value="Submit" />
</form>
This is my Node.js code:
app.post('/myform', function(req, res){
console.log(req.body.mytext); //mytext is the name of your input box
});
I am getting this error:
TypeError: Cannot read properties of undefined (reading 'mytext')
Please help me out.