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 trialMartin Coutts
18,154 PointsWhen I type in username, eg. add /chalkers to URL then it comes up workspace unavailable
As said in the title I have followed the video but when I try to add a username my code does not act the same way. I have a feeling it has something to do with the line response.write(username - "\n");
in the Get username block //Handle HTTP route GET / username i.e /chalkers function user (request, response) { //if URL == "/....." var username = request.url.replace("/", ""); if (username.length > 0) { response.statusCode = 200; response.setHeader('Content-Type', 'text/plain'); response.write("Header\n"); response.write(username - "\n"); response.end('Footer\n'); } }
On the video the dash symbol in the response.write is blue but on my programme it is yellow so I'm wondering if it is a special character that I just can't make out on the video.
2 Answers
Martin Coutts
18,154 PointsI had a look, it just has links to the different documentations, I had a look through the response.write link but couldn't see anything specific to this issue.
jb30
44,807 PointsInstead of response.write(username - "\n");
, try response.write(username + "\n");
. The +
operator concatenates two strings, so "Hello" + " world"
becomes "Hello world"
, and username + "\n"
becomes the value of the variable username
followed by a line break.
Jamie Carter
Front End Web Development Techdegree Student 12,096 PointsJamie Carter
Front End Web Development Techdegree Student 12,096 PointsCheck the video note section as they mention something you need to change to make this ork with their updated API if i remember correctly