I am trying to use Bodyparser in my code but the code is cut by the editor itself and says body-parser is deprecated. I tried some alternative codes I found online but none of those are working. Attached is the screenshot of the code I am using.Code
Code:
const express = require("express");
const bodyParser = require("body-parser");
const app = express()
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get("/", function(req, res){
res.sendFile(__dirname + "/index.html");
});
app.post("/", function(req, res){
var num1 = req.body.num1;
var num2 = req.body.num2;
var result = num1 + num2;
res.send("The result of the calculation is " + result);
});
app.listen(3000, function(){
console.log("Server has started on port3000");
});