Search code examples
javascriptnode.jsexpressbody-parser

Why am I getting 'bodyParser' is deprecated warning?


I used the latest version of both packages but still, I am getting 'bodyParser' is a deprecated warning. It is not affecting my code but why is this happening?

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

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

app.listen(port, () => {
    console.log(`Welcome to ${port}`);
});

Solution

  • It means that body-parser want you to use a different method (.json() or .urlencoded()):

    https://github.com/expressjs/body-parser/commit/b7420f8dc5c8b17a277c9e50d72bbaf3086a3900