I Have the following HTML Form:
<form class="" action="/" method="post">
<input type="text" name="num1" placeholder="First Number">
<input type="text" name="num2" placeholder="Second Number">
<button type="submit" name="submit">Calculate</button>
</form>
What I want to do is to get the two entered numbers and post their sum. In my express.js server, I included the body-parser package and when I write the following route:
app.post("/", function(req,res) {
var num1 = Number(req.body.num1);
var num2 = Number(req.body.num2);
res.send(num1+num2);
})
After pressing the submit button, I get the following error showing:
RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 5
I also tried using the parseInt() function but it displayed the same error.
What does this error mean? And how can I fix it?