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 Adding Multiple Routes to the App

ReferenceError: response is not defined

"I'm running this on Atom:"

ReferenceError: response is not defined

app.js

const express = require('express');

const app = express();


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

app.listen(3000);     // Sets up the development server

pacage.json

{
  "name": "multiple-routes",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.2",
    "nodemon": "^1.14.11"
  }
}

This is a review for me. The first time through I used Workspaces and everything worked fine. Today I am trying to get the same results on my own machine and I'm running into trouble.

  • node_modules - Installed
  • Express - Installed
  • Nodemon - Installed

Best vote get points =)

Cheers!

1 Answer

Joel Bardsley
Joel Bardsley
31,249 Points
app.get('/', (req,res) => {
  response.send('I love Treehouse!');
});

Response is not defined since you've called your arguments 'req' and 'res' for short, so you need to use res.send in this instance.

By golly! I always miss the little stuff.

Cheers!