Using express 3.1.0 I have a super simple form:
Your example works for me. I removed the references to User, user, and routes so that I can run it and the HTTP POST is received and displayed correctly in the console.
app.post('/signup', function(req, res) {
var username = req.body.username;
var password = req.body.password;
console.log("post received: %s %s", username, password);
});
I suspect the error is in your User.addUser() code.
router.route('/signup')
// (accessed at POST http://localhost:3000/api/signup)
.post(function(req, res) {
var username = req.body.username;
var password = req.body.password;
res.json(
{
message: 'signup success',
username : username,
password : password,
}
);
})
.get(function(req,res){
res.json({message: 'get request from signup'});
});
// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', router);
You can write something like this:
action="http://localhost:3000/sin"