bodyParser is deprecated express 4
Full error message
I am using express 4.0 and I'm aware that body parser has been taken out of the express core, I am using the recommended replacement, however I am getting
body-parser deprecated bodyParser: use individual json/urlencoded middlewares server.js:15:12
body-parser deprecated urlencoded: explicitly specify "extended: true" for extended parsing node_modules/body-parser/index.js:74:29
Where do I find this supposed middlewares? or should I not be getting this error?
var express = require('express');
var server = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var passport = require('./config/passport');
var routes = require('./routes');
mongoose.connect('mongodb://localhost/myapp', function(err) {
if(err) throw err;
});
server.set('view engine', 'jade');
server.set('views', __dirname + '/views');
server.use(bodyParser());
server.use(passport.initialize());
// Application Level Routes
routes(server, passport);
server.use(express.static(__dirname + '/public'));
server.listen(3000);Solutionsource: stackoverflow \u2197
It means that using the bodyParser() constructor has been deprecated, as of 2014-06-19. app.use(bodyParser()); //Now deprecated You now need to call the methods separately app.use(bodyParser.urlencoded()); app.use(bodyParser.json()); And so on. If you're still getting a warning with urlencoded you need to use app.use(bodyParser.urlencoded({ extended: true })); The extended config object key now needs to be explicitly passed, since it now has no default value. If you are using Express >= 4.16.0, body parser has been re-added under the methods express.json() and express.urlencoded().
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/fb1ce00bfbb8cfd7ec7d7dcf60a77206de40ff1bc260994e4b7b3af7ea0dc950hash \u00b7 fb1ce00bfbb8cfd7ec7d7dcf60a77206de40ff1bc260994e4b7b3af7ea0dc950