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.
'Programming > JavaScript, Node.js' 카테고리의 다른 글
4 + 1 ways for making HTTP requests with Node.js: async/await edition (0) | 2021.06.11 |
---|---|
Node.js vs Java: What to Choose in 2021? (0) | 2021.05.19 |
JavaScript Standard Style (0) | 2021.05.12 |
AWS Lambda function handler in Node.js (0) | 2021.05.12 |
How To Use JSON Web Tokens (JWTs) in Express.js (0) | 2021.03.31 |
댓글