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 Getting Started with Express Setting Up a Basic Express App

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

Response is not defined

Hello I am unable to complete the first segment of the code quiz with this code that should be correct

I have shortened request to "req" and response to "res" as instructed in the previous video https://teamtreehouse.com/library/adding-multiple-routes-to-the-app @55 seconds

what am i doing wrong?

Code quiz: https://teamtreehouse.com/library/express-basics-2/getting-started-with-express/setting-up-a-basic-express-app


const express = require('express');

const app = express();

app.get('/', (req, res) => { response.send("I Love Treehouse!"); });

app.listen(3000);


app.js
const express = require('express');

const app = express();

app.get('/', (req, res) => {
  response.send("I Love Treehouse!");
});

app.listen(3000);

1 Answer

Ari Misha
Ari Misha
19,323 Points

Hello there! You're almost there, Kevin Ohlsson ! You forgot to change the response to res in the local scope of the callback. Here is how your code should look like:

const express = require('express');

const app = express();

app.get('/', (req, res) => {
  res.send("I Love Treehouse!");
});

app.listen(3000);

I hope it helped!

~ Ari

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

Thanks Ari!

Back on track now!