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 Handling Parsing and Status Code Errors

zachstockmal
zachstockmal
6,413 Points

Why is my console printing "There was an error getting the profile for chalker123. ([object Object])"

Here is my workspace:

https://w.trhou.se/stqketps8m

There must be some line of code I missed somewhere or maybe a typo but I'm not seeing it right now. If anyone else does that would be so wonderful!

1 Answer

Seth Reece
Seth Reece
32,867 Points

There is no chalkers123 profile. His profile is just chalkers.

zachstockmal
zachstockmal
6,413 Points

True, but in the video it came up with (Not found) in the message and I got ([object Object]). I'm wondering why that error message didn't go through. I was just trying to also get that error message.

Seth Reece
Seth Reece
32,867 Points

You need to pass in response.statusCode to http.STATUS_CODES.

From theAPI docs,

"http.STATUS_CODES Object A collection of all the standard HTTP response status codes, and the short description of each. For example, http.STATUS_CODES[404] === 'Not Found'."

So you want:

http.STATUS_CODES[response.statusCode]

and you are good to go.

zachstockmal
zachstockmal
6,413 Points

Awesome that worked! Thank you.