"Build a Blog Reader iPhone App" was retired on May 31, 2020.

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

Status message error working without 'http' module

Hi, I tried to print the error message without require 'http' module and it's work. I've just written ${response.statusMessage} in my message. I didn't even to use STATUS_CODES array.

I use the v8.11.1. Maybe this issue was updated with this version ?

         const https = require('https');
function printError(error){
    console.error(error.message); 
}

[...]

function get(username){
    try{
        const request = https.get(`https://teamtreehouse.com/${username}.json`, (response) => {

            if(response.statusCode === 200){
            [...]
            } else{
                const message = `There is an error getting the profile for ${username} with error (${response.statusCode} = ${response.statusMessage})`;
                const statusCodeError = new Error (message);
                printError(statusCodeError);
            }
        });

        request.on('error', error => { printError } ); 
    } catch (error){
        printError(error); 
    }
};
    ```

Please show we your code.