I am following a tutorial to build a node/express app using the jade templating engine and I am getting a 404 error when I try to submit a form. For my routing I have the line app.post('/sign_up', sign_up);
which gives me an error. The sign_up
variable is declared above using this line var sign_up = require('./routes/sign_up');
.
The strange thing is if I register a callback function in the place of the sign_up
variable then I can retrieve the data fine, which I did using this code
app.post('/sign_up', function(req, res){
console.log(req.body);
});
.
In my routes folder I have got the sign_up.js file and which outputs a rather simple line of text. I have tried changing the function
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('You signed up');
});
module.exports = router;
Below are the contents of my form.jade file
extends layout
block content
h1= title
form(name="sign-up", action="/sign_up", method="post")
div
label Username:
input(type="text", name="username")
div
label Password:
input(type="password", name="password")
div
input(type="submit", value="Sign Up")