'email' 的 属性 未定义

Property of 'email' undefine

我正在关注 RESTful API 系列的 Academind 并且我已经添加了用户注册但是我收到错误 无法读取 属性 'email'未定义 邮递员以 json 的原始格式传递以下 json 数据后,邮递员的所有内容都按照学术视频中的配置进行配置。

{
    "email" : "test@test.com",
    "password" : "tester"
}

我的 routes/users.js 看起来像这样:

const express = require('express');
const router = express.Router();
const mongoose = require("mongoose");
const bcrypt = require("bcrypt");

const User = require("../models/user");

router.post('/signup', (res, req, next) => { 
    // console.log(req.body.email);
    User.find({ email: req.body.email })
    .exec()
    .then(user => {
        if ( user.length >= 1 ) {
            return res.status(409).json({
                message: 'Email already in use by some other user'
            });
        } else {
            bcrypt.hash(req.body.password, 10, (err, hash) => {
                if (err) {
                    return res.status(500).json({
                        error: err,
                    });
                } else {
                    // console.log(req.body.email);
                    const user = new User({
                        _id: new mongoose.Types.ObjectId(),
                        email: req.body.email,
                        password: hash,
                    });
                    user
                    .save()
                    .then(result => {
                        console.log(result);
                        res.status(201).json({
                            message: "User Created Successfully",
                        });
                    })
                    .catch(err => {
                        console.log(err);
                        res.status(500).json({
                            error: err
                        });
                    });
                }
            });
        }
    });
});

module.exports = router;

这一行:

router.post('/signup', (res, req, next) => { 

箭头函数中的参数应该是这样的(req, res, next)=> 即参数中“req”出现在“res”之前。 像这样:router.post('/signup', (req, res, next) => {