Hi I am currently learning NodeJS and the Express framework, but I am having issue with when I try to submit the form it suppose to go the '/users/register' URL but it seems that my app.js is not finding the register.jade file although I have a register.jade under the view folder. Here is some of my codes:
register.jade:
extends layout
block content
h1 Register
p Please register using the form below
ul.errors
if errors
each error, i in errors
li.alert.alert-danger #{error.msg}
form(method='post', action='/users/register', enctype='multipart/form-data') ...
user.js:
router.post('/users/register', function(req, res, next) { ... });
app.js:
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var expressValidator = require('express-validator');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var passport = require('passport');
var local = require('passport-local').Strategy;
var bodyParser = require('body-parser');
var multer = require('multer');
var flash = require('connect-flash');
var mongo = require('mongodb');
var mongoose = require('mongoose');
var db = mongoose.connection;
var index = require('./routes/index');
var users = require('./routes/users');
var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
...
app.use('/', index);
app.use('/users', users);
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
Error on my Git Bash:
Error from the browser:
Here is my folder structure:
I am not sure why it errors out 404, thank you in advance!
via Cham
No comments:
Post a Comment