본문 바로가기
  • AI (Artificial Intelligence)
Programming/JavaScript, Node.js

Express 4.16.0 - Release date: 2017-09-28

by 로샤스 2021. 5. 12.

Ref. stackoverflow.com/questions/24330014/bodyparser-is-deprecated-express-4

Use it like this:

// Express v4.16.0 and higher
// --------------------------
const express = require('express');

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

// For Express version less than 4.16.0
// ------------------------------------
const bodyParser = require('body-parser');

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

Explanation: The default value of the extended option has been deprecated, meaning you need to explicitly pass true or false value.

Note for Express 4.16.0 and higher: body parser has been re-added to provide request body parsing support out-of-the-box.

 

댓글