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

JavaScript Express Basics (2015) Doing more with Express Making Lists in Jade Templates

Not getting posts object

When I run post in the console, I don't get anything. There are no Objects returned.

If I just go ahead and write out the map function, I get:

Object.keys(posts).map(function(value){return posts[value]})
TypeError: Cannot convert undefined or null to object
No Properties
Runtime.getProperties failed.
Object #null# not found

My app.js file:

'use strict';

var express = require('express'),
    posts = require('./mock/posts.json');

var app = express(); 

app.use('/static', express.static(__dirname + '/public'))

app.set('view engine', 'jade');
app.set('views', __dirname + '/templates')

app.get('/', function(req, res){

app.get('/blog/:title?', function(req, res){
    var title = req.params.title;
    if (title === undefined){
        } else {
        var post = posts[title] || {};
        res.render('post', { post: post}); 

app.listen(3000, function(){
    console.log("the frontend server is running on port 3000");

Overall, it's like something happened between the last set of videos and this set that changed. I'm not sure what it is. Even localhost:3000 isn't working. I get a "This webpage is not available; ERR_CONNECTION_REFUSED" error when I reload the page.

Casey Ydenberg
Casey Ydenberg
15,622 Points

If localhost:3000 isn't working, there's something deeper wrong. Is your App running when you make the request? Can you see the requests coming in through the console? Remember, Node is not like Ruby or PHP or Python. The program has to be running all the time.

Hi Casey,

Sorry if I wasn't clear. Localhost isn't working with the new code, as I posted. Localhost does work with the previous version, where the response is "This page is under construction!". What I posted is basically where things broke down.

1 Answer

Don't forget that in this video we ran the command 'nodemon --debug-brk src/app' command and the 'node-inspector'.

This means that each time the server restarts, it will stop the app before it can actually do anything, and you'll have to hit the "play" button in the Node Inspector browser window.

You might want to stop that process and restart the server with the other command line, 'nodemon src/app'.