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 Handling Errors in Node Handling Errors in Node

Johannes Scribante
Johannes Scribante
19,175 Points

Code challenge error is not helping me to find my error

Code Challenge: Create a variable request that stores the result of the get method. Error message: Bummer! You didn't declare the var, const or let variable.

I have tried many variations, but I get the same error and cannot figure out why I get this error. As the piece of code I write is: let request = ""; or respone.on('data', data => { let request = data.toString(); }); and some other variations in between.

Am I understanding the code challenge incorrectly? or is there something wrong with my code?

app.js
const https = require("https");

https.get("https://teamtreehouse.com/chalkers.json", response => {
  console.log(response.statusCode);
  let request = response.result;
});

2 Answers

Alexandra Barnett
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 Points

Hi Johannes! The challenge wants you to assign the whole get request to the variable request (like below). I think it's a case of it being simpler than you or I might expect :)

const https = require("https");

const request = https.get("https://teamtreehouse.com/chalkers.json", response => {
  console.log(response.statusCode);
});

Hope that helps! :)

Johannes Scribante
Johannes Scribante
19,175 Points

Thanks Alexandra, your answer worked 100s! sometimes you just overthink these challenges!