Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Node.js Basics!
You have completed Node.js Basics!
Preview
Request errors can come with status codes that tell us more about the type of error that occurred.
Documentation
Snippets
function printError(error) {
console.error(error.message);
}
const message = `There was an error getting the profile for ${username} (${http.STATUS_CODES[response.statusCode]})`;
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We can call this function
in all of our handlers and
0:03
replace the statements
that are currently there.
0:05
So in our try block.
0:10
PrintError.
0:15
Save, Same here in our on method.
0:20
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up