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 trialsam poplack
9,467 PointsHow do I fix this error on my code to make it run properly
I Have been Working on this along with the lecture
const https = require('https');
function ptintMessage(username, badgecount, point) {
const message = `${username} has ${badgecount} total badge(s) and ${point} points in Jscript`;
console.log(message);
}
function getProfile(username) {
//connect to api url (https://teamtreehouse.com/username.json)
conts request = https.get(`https://teamtreehouse.com/${username}.json`, response => {
let body = "";
console.log(response.statusCode);
response.on('data', data => {
body + data.toString();
});
response.on('end', () => {
const profile = JSON.parse(body);
console.dir(profile);
printMessage(username, profile.badges.length, profile.points.JavaScript);
});
});
}
In the Comand line it says that an error was thrown on the request variable here:
conts request = https.get(https://teamtreehouse.com/${username}.json
, response => {
Can someone show me what went wrong by chance?
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsone thing i see is that you misspelled printMessage as ptintMessage when you defined the function.
Nikola Jankovic
10,793 PointsMisspelled conts request= > const request
Nikola Jankovic
10,793 Pointsbody + data.toString(); => body += data.toString();
Nikola Jankovic
10,793 Pointsfunction ptintMessage => function printMessage