我正在使用Express 4.0,并且我知道主体解析器已从Express核心中移除,我正在使用推荐的替代产品,但是我正在
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
我在哪里可以找到这个所谓的中间件?还是我不应该得到这个错误?
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);
app.use(bodyParser.urlencoded({extended: true}));
我有同样的问题,但这对我有用。您可以尝试此扩展部分。