Sai Krishnadas
Sai Krishnadas

Reputation: 3409

'bodyParser' is deprecated in node v14

code :

const express = require("express");
const bodyParser = require("body-parser");

const app = express();
app.use(bodyParser.urlencoded({extended:true}));

app.get("/",function(req,res){
    res.sendFile(__dirname + "/index.html");
})

app.listen(3000,function(){
    console.log("Server started on port 3000");
})

I have installed body-parser with npm i body-parser and required it. But it shows "bodyParser" is deprecated with a crossed line in app.use(bodyParser)

node version : v14.17.1

Upvotes: 1

Views: 855

Answers (1)

Brendan Bond
Brendan Bond

Reputation: 1890

body-parser is not deprecated in node 14, it's deprecated in Express.

app.use(express.urlencoded({extended: true}));

Upvotes: 4

Related Questions