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 trialMarina Emmatty
620 Pointsmy Task 1 fails when i try to run task 3
am i putting try and catch at wrong place?
const https = require("https");
try {
const request=https.get("https://teamtreehouse.com/chalkers.json", response => {
console.log(response.statusCode);
});
request.on('error',error=>console.error('problem with request:${error.message}'));
}
catch(error){
console.error(error.message);
}
1 Answer
Steven Parker
231,261 PointsYou don't need a try or catch for this challenge.
The instructions for task 3 are: "Finally, in the error callback, use the error method on the console to print out the error message."
So you can leave off the try and the entire catch block. But then there's still a few issues:
- an interpolated string should be enclosed with accents, not apostrophes
- the challenge isn't prepared to evaluate the output with an additional string added anyway
- apparently either the on method or the "check work" mechanism rely on the arguments object
- no arguments object is created when the "arrow" function notation is used, use the conventional notation instead