Unhandled rejection TypeError: res.sendStatus is not a function

Unhandled rejection TypeError: res.sendStatus is not a function

我在我的应用程序中遇到了这个奇怪的错误。正如您在 package.json 中看到的那样,express 版本是 > 4.x.

{
  "name": "MyAPI",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "bcrypt": "^0.8.6",
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "pg": "^4.5.5",
    "pg-hstore": "^2.3.2",
    "sequelize": "^3.23.2",
    "sequelize-cli": "^2.4.0",
    "serve-favicon": "~2.3.0",
    "validator": "^5.2.0"
  }
}

这是源代码

'use strict';
var express = require('express');
var router = express.Router();
var version = require('../package.json').version;
var sequelize = require('sequelize');

var userAccounts = require('../models').user_account;

router.post('/v' + version + '/register', function (res, req, next) {
    userAccounts.create(req.body).then(function () {
        next();
        return res.sendStatus(200).send({ message: ":D" });
    });
});

module.exports = router;

我也尝试将 sendStatus 更改为 status,但错误提示 status 也是如此。为什么我会收到这些错误?

快速处理函数的参数 resreq 顺序错误。它们应该是:

function (req, res, next) {}