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 trialZach Freitag
20,341 PointsWhy not working? My code is perfect. https://teamtreehouse.com/workspaces/33084322#
Why isn’t this working? It should be perfect.
ERROR MESSAGE: “SyntaxError: Unexpected token” https://teamtreehouse.com/workspaces/changelog
MY CODE BELOW:
const https = require('https');
function printMessage(username, badgeCount, points) { const message = ${username} has ${badgeCount} total badge(s) and ${points} in JavaScript ; console.log(message); }
function getProfile(username){
const request = https.get(https://teamtreehouse.com/${username}.json
, response => {
let body = "";
response.on('data', data => {
body += data.toString();
});
response.on('end', () => { const profile = JSON.parse(body); printMessage(username, profile.badges.length, profile.points.JavaScript); });
});
}
getProfile("chalkers"); getProfile("alenaholligan");
2 Answers
Dave StSomeWhere
19,870 PointsI'm pretty sure that there is no such thing as perfect code. hehe
Don't you at least need tics for your template code?
Pepe Toño
13,815 PointsYou are missing inverted ticks on the first argument of the https.get() method. Write it like this https://teamtreehouse.com/${username}.json
Steven Parker
231,059 PointsSteven Parker
231,059 PointsIf there was "perfect" code, you'd never have to ask why it wasn't working.