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 Deeper into Routing with Express Review Adding Multiple Routes

Jason Nutt
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jason Nutt
Front End Web Development Techdegree Graduate 24,760 Points

Use the send method on the response object to return the 'posts' object when /blog route is requested...I think I am?

const express = require('express'); const posts = require("./mock/posts.json");

const app = express();

app.get('/', (req, res) => { res.send("<h1>I Love Treehouse!</h1>"); }); app.get('/blog', (req, res) => { res.send('posts'); }); app.listen(3000, () => { console.log("The frontend server is running on port 3000!") });

app.js
const express = require('express');
const posts = require("./mock/posts.json");

const app = express();

app.get('/', (req, res) => {
  res.send("<h1>I Love Treehouse!</h1>");
});
app.get('/blog', (req, res) => {
  res.send('posts');
});
app.listen(3000, () => {
  console.log("The frontend server is running on port 3000!")
});

3 Answers

Hi Jason!

Your problem is simple.

posts is a variable, so it does not need to be in quotes.

Lose them and you'll be OK.

This:

res.send('posts');

Should be"

res.send( posts );

I hope that helps.

Stay safe and happy coding!

No worries...it's a common/easy mistake to make...

Have a great week! (I can't believe it's March already!?! LOL)

PS: I don't know if it's your thing, but I'm telling everyone about it. If you haven't seen Resident Alien on the Sci-Fi channel it's hilarious! (SOOOOOOO funny!). You can watch it On Demand or on the website (as well as on the Sci-Fi channel). They've run 5 episodes so far - each one better than the last - and episode #6 will air 10:00 pm this coming-up Wednesday - can't wait!?! Late'