Express正在发送一个对象,里面有一个对象

我有一个连接到Mongoose数据库的Express服务器(我的术语可能不正确,因为我刚开始学习Express)。 当我访问一个/pipe理员(路线?)我收到一个对象与我的JSON对象里面。

我发错了吗?

var userSchema = new Schema({ firstName: {type: String, trim: true}, lastName: {type: String, trim: true}, classYear: Number, email: {type: String, unique: true, sparse: true, trim: true}, phone: {type: String, unique: true, sparse: true}, phoneProvider: {type: String, trim: true}, isAdmin: {type: Boolean, index: true}, isSuperAdmin: {type: Boolean, index: true}, hash: String, companyName: {type: String, trim: true}, interests: [String], }, { toObject: { getters: true }, timeStamps: { createdAt: 'createdDate', updatedAt: 'updatedDate' } } ); 

部分admins.js

 exports.createAdmin = function(req, res, next) { if (typeof req.body.email !== 'string') return res.status(400).send('Missing email'); if (typeof req.body.password !== 'string' && typeof req.body.hash !== 'string') return res.status(400).send('Missing password'); if (typeof req.body.companyName !== 'string') return res.status(400).send('Missing companyName'); 

req.body.email返回为undefined。 收到的JSON如下所示:

 { '{\n\temail:'an@email.com'}': ''} 

这是我的路线/pipe理员:

 app.post('/admins', admins.createAdmin); 

这是我的中间件:

 app.param('id', function(req, res, next, id) { if (!id.match(/^[0-9a-fA-F]{24}$/)) return res.status(400).send('Invalid ID'); next(); });