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 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