Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Cory Rabiea
5,561 Pointsdebugger: req is not defined?
I'm going through the "Requests and the request object" step in the express course and I can't seem to call the request object in my debugger. I set my break point for the body of my blog route and it seems to hit it, but I always seem to get the error "Uncaught ReferenceError: req is not defined".
Just as well, I don't see the call stack populating with anything either. Am I not actually hitting the breakpoint? Any thoughts?
here is my app.js
'use strict';
var express = require('express'),
posts = require('./mock/posts.json');
var app = express();
app.get('/', function(req, res){
res.send("<h1>Hello there!</h1>")
});
app.get('/blog', function(req, res){
res.send(posts);
});
app.listen(3000, function(){
console.log("Front-End Server is running on port 3000")
});
1 Answer
Cory Rabiea
5,561 PointsFigured it out, just in case anyone also had this problem:
Looks like I was using Google Chrome's own javascript console instead of Node-Inspector's console. Boy do I feel silly.
Cory Rabiea
5,561 PointsCory Rabiea
5,561 PointsSo it turns out it wasn't hitting the breakpoint. Now it is and the call stack is populating but I still keep getting the error that req is not defined?