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 Build a Simple Dynamic Site with Node.js Handling Routes in Node.js User Route

Workspace unavailable when I access port 3000

Workspace Unavailable This is a preview link for a Treehouse Workspace that is not currently active.

If you are the workspace owner, you can launch it again via the Treehouse site.

2 Answers

Did you enter node app.js in the console prior to the preview?

treehouse:~/workspace$ node app.js                                                       
Server running at http://<workspace-url>/      

Yes typed in the command to execute the server in Node.js.

Server running at http://<workspace-url>/
/home/treehouse/workspace/router.js:18
const username = request.url.replace("/", "");
^

ReferenceError: request is not defined
at Object.user (/home/treehouse/workspace/router.js:18:20)
at Server.<anonymous> (/home/treehouse/workspace/app.js:11:12)
at emitTwo (events.js:126:13)
at Server.emit (events.js:214:7)
at parserOnIncoming (_http_server.js:660:12)

This is what happens to me, even though using Treehouse own workspace.

Is request a parameter of the function, or did you use req?