Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics (2014) Building a Command Line Application Getting the Response Body

Nothing working except statusCode

Hi, I have been following this video and couldn't get anything showing on the console except for the first statusCode log.

None of the on methods worked either on treehouse console or my own terminal Do you know why this could be? (I made sure that my code was exactly as on the screen.)

Thanks,

Trixi

3 Answers

Hi Trixi, Even i was having the same issue. but a there is trick to have everything sorted. i guess the tutorial was not updated with the changes made in the Teamtreehouse website. The teamtreehouse website now uses a 'HTTPS' request and not 'HTTP' request as shown in the tutorial. Please update your code as follows

var http = require('https');

var username = 'yourusername';

var request = http.get('https://teamtreehouse.com/'+username+'.json', function(response) { console.log(response.socket._handle.bytesRead);
response.on('data', function(chunk){ console.log('BODY: ' + chunk); }); });

request.on('error', function(error) { console.error(error.message); });

Hi Trixi,

I would need to view the code in your app.js file to view where the issue is. Can you add your code to this thread please?

Corina Meyer
Corina Meyer
9,990 Points

have a look at this question. might solve your problem: https://teamtreehouse.com/community/getting-a-301-error