• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

270
Vistas
BodyParser is deprecated

enter image description here

As the image shown, BodyParser now is deprecated, how to correct the bodyParser syntax or statement to remove the line-through?

over 3 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Don't use body-parser

body parsing has become builtin with express So, simply use

app.use(express.json()) //For JSON requests
app.use(express.urlencoded({extended: true}));

from directly express

You can uninstall body-parser using npm uninstall body-parser



Then you can simply get the POST content from req.body

app.post("/yourpath", (req, res)=>{

    var postData = req.body;

    //Or like this, for string JSON body

    var postData = JSON.parse(req.body);
});
over 3 years ago · Santiago Trujillo Denunciar

0

Same issue occur to my projects also . Now in latest express we don't need to import body-parse, we can just use express as follow.

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

or if you limit size

app.use(express.urlencoded({ limit: "50mb", parameterLimit: 500000000 }));
over 3 years ago · Santiago Trujillo Denunciar

0

If you are using Express 4.16+ you don't have to import body-parser anymore. You can do it just like this:

app.use(express.urlencoded({extended: true}));
app.use(express.json()) // To parse the incoming requests with JSON payloads
over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda