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 trialErik L
Full Stack JavaScript Techdegree Graduate 19,470 Pointsmy code is not working
hello, I am doing this video: https://teamtreehouse.com/library/making-a-get-request-with-https, the console is showing me an error when I try to console.log message, this is my code:
// Problem: We need a simple way to look at a user's badge count and JavaScript points
// Solution: Use Node.js to connect to Treehouse's API to get profile information to print out
const username = "chalkers";
//Require
const https = require('https')
//Function to print message to console
function printMessage(userName, badgeCount, points) {
const message = `${userName} has ${badgeCount} total badge(s) and ${points} points in Javascript`;
console.log(message)
}
printMessage("chalkers", 100, 2000);
//Connect to the API URL (https://teamtreehouse.com/username.json)
const request = http.get('https://teamtreehouse.com/${username}.json', response => {
//Read the data
//Parse the data
//Print the data
console.log(response);
});
can someone please help
1 Answer
Elijah Quesada
Front End Web Development Techdegree Graduate 32,965 PointsLooks like there's a typo with http.get. It should be https.get
//Connect to the API URL (https://teamtreehouse.com/username.json)
const request = https.get('https://teamtreehouse.com/${username}.json', response => {
//Read the data
//Parse the data
//Print the data
console.log(response);
});