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 trialmattcleary2
19,953 PointsSo when does the program connect to Treehouse in order to get the profile information?
Hey guys,
I'm a little confused. Where in the program do we actually connect to Treehouse in order to get the profile stats?
Thankyou
3 Answers
Seth Kroger
56,413 PointsIt should be specified in profile.js which is responsible for fetching and populating the profile info.
Jesus Mendoza
23,289 PointsWhen you run your program with node server.js the program keeps running in the background waiting for an event to happen, when it gets a request to '/:username' (which is supposed to happen when you click the search button or enter the username manually to the url) then it connects to Treehouse and gets the data corresponding to that user
mattcleary2
19,953 PointsThanks for responding so quickly. What I mean though, is how does it know to connect to TREEHOUSE itself? Where did we specify to go to it?
Aurelian Spodarec
10,801 PointsDNS, Google that. Maybe. Or protocols. Or just programmatically made so when you type so Etching in the URL it will show info, these links are nice, but yiu need to programme for them yo be nice, since that's not default.
Pedro Esteves
13,125 PointsWhen you fill out the search form, you're doing a post request with that username.
On the router.js, on the home function, we first handle the GET request (when you enter the webpage), but then we handle the POST request - that's when you insert the username in the search form - it redirects you to the user function that handles the URL with the username, fetches the information of that username from treehouse (var studentProfile = new Profile(username);) and then we writes the response.