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 trialAsaf Tzarfaty
3,740 PointsWhy do I get "Workspace Unavailable"?
I'm using the same code has in the lesson, this one:
var Profile = require("./profile.js");
function homeRoute(request,response){ if(request.url === '/'){ response.writeHead(200,{'Content-Type':'text/plain'}); response.write("Header\n"); response.write("Search\n"); response.end("Footer\n"); } }
function userRoute(request,response){ var username = request.url.replace("/",""); if(username.length>0){ response.writeHead(200,{'Content-Type':'text/plain'}); response.write("Header\n");
var studentProfile = new Profile(username);
studentProfile.on("end", function(profileJSON){ var values = { avatarUrl: profileJSON.gravatar_url, username: profileJSON.profile_name, badges: profileJSON.badges.length, points: profileJSON.points.JavaScript } response.write(values.username+" has "+values.badges+ " badges \n"); response.end("Footer\n"); }); } }
module.exports.home = homeRoute; module.exports.user = userRoute;
And it runs well, but when I'm adding my name to the address it sends me to "Workspace Unavailable" page, why?
thanks
Alexei Parphyonov
34,128 PointsAlexei Parphyonov
34,128 PointsYou need to type 'node app.js' in the console first before previewing it with this or that port. Then keep it running and do not press CTRL+C if you want it to be previewed.