Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on first load #1

Closed
chintanp opened this issue Sep 28, 2015 · 1 comment
Closed

Error on first load #1

chintanp opened this issue Sep 28, 2015 · 1 comment

Comments

@chintanp
Copy link

Hey,

Congrats on a great article. It has quite an exhaustive coverage of technologies. Jade isnt my favorite and maybe the error I got was due to a typo or some such. But I am not able to move forward. After following up with your code and typing it up (mostly), and removing basic errors, I am getting the following stack trace in the browser,

TypeError: Cannot read property 'error' of undefined
    at router.get.errorMessage (G:\angular\iot.me\IoT.me\routes\index.js:88:32)
    at Layer.handle [as handle_request]    (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\layer.js:95:5)
    at next (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\route.js:131:13)
    at Route.dispatch (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\layer.js:95:5)
    at G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:277:22
    at Function.process_params (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:330:12)
    at next (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:271:10)
    at Function.handle (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:176:3)
    at router (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:46:12)
    at Layer.handle [as handle_request] (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:312:13)
    at G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:280:7
    at Function.process_params (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:330:12)
    at next (G:\angular\iot.me\IoT.me\node_modules\express\lib\router\index.js:271:10)
    at SendStream.error (G:\angular\iot.me\IoT.me\node_modules\express\node_modules\serve-static\index.js:120:7)

I also started the app in debug mode using
set DEBUG=express:* & nodemon bin/www

I get following lines with pink color in my command prompt

 express:view lookup "error.jade" +6ms
 express:view stat "G:\angular\iot.me\IoT.me\views\error.jade" +1ms
 express:view render "G:\angular\iot.me\IoT.me\views\error.jade" +1ms
 GET / 500 124.358 ms - 2293

Typically, I would fire up my webstorm at this point, but am trying to explore other options at debugging this. I must also mention that I am suing Windows 7 in place of Ubuntu as you do, and I have a mongod instance running.

@amatelin
Copy link
Owner

I can't replicate the error on my side. From what I understand the error must be happening when req.session.error is invoked in one of the routes from the 'index.js' file. Is your express-session middleware running correctly ? You can add this as a last middleware in app.js in order to check that a session was indeed created.

app.use(function(req, res, next) {
    console.log(req.session);
    next();
})

This should print something like:
{ cookie:
{ path: '/',
_expires: null,
originalMaxAge: null,
httpOnly: true } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants