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 2017 Building a Command Line Application Getting the Response Body

What is the statusCode?

I very new to note. Please someone help me to understand the statusCode!

Mark Rinkel
Mark Rinkel
13,501 Points

They tell you the status of the page. Here's a list: https://www.restapitutorial.com/httpstatuscodes.html

2 Answers

Dilip Agheda
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dilip Agheda
Full Stack JavaScript Techdegree Graduate 28,581 Points

Benjamin Mercier status code is not a node specific concept. it is more related to HTTP protocol in general. statusCode basically means that every time, when a http request is made it results in a response that has some sort of status code to indicate what happened to that http request.

in a typical scenario, when http request is successful, status code is 200 which means "OK". similarly 404 means file not found. checkout this wiki - https://en.wikipedia.org/wiki/List_of_HTTP_status_codes for more info.

remedies
remedies
3,616 Points

statusCode is an object property related to HTTP requests. Basically, when making an HTTP request, you get a response object. This response object contains properties that you can access.

It's just like any other javascript object. This:

var person = {
    name : "John Doe",
    number : "123-1231"
};

console.log(person.name);

would return the person's name. Imagine the response object being structured the same way. It would contain various properties and methods.

var response = {
    statusCode : "200"....
};