I got this strange error in my application. As you can see in the package.json
the express
version is > 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"
}
}
Here is the source code
'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;
I also tried to change the sendStatus
to status
but the error says the same thing about status
too. why I am getting these errors?
The arguments res
and req
of the express handler function are in wrong order. They should be:
function (req, res, next) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With