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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Madeline Yao](https://secure.gravatar.com/avatar/bb01fe9aa62a1d1f3662d4e0875998ed?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Madeline Yao
Full Stack JavaScript Techdegree Student 9,611 PointsWhy we need to require module in order to gain information from API?
// 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
//Require https module const https = require('https'); const username = "chalkers";
//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);
}
// Connect to the API URL (https://teamtreehouse.com/username.json)
const request = https.get(https://teamtreehouse.com/${username}.json
, response => {
console.log(response.statusCode);
// Read the data
// Parse the data
// Print the data
});
In the video tutorial, I notice that when you do not require https, you cannot get information from API. I wonder why that happens. Could anyone please explain to me about that and the importance of the module? Thank you!
3 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe "https" module contains the code for the "https.get" method that the code is using to perform the request.
![Routine Poutine](https://uploads.teamtreehouse.com/production/profile-photos/9710132/micro_514px-Food_at_WIkimanian_2017_02.jpg)
Routine Poutine
26,050 PointsIs a module another word for snippet?
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsA "module" would be less than a whole program, but it would typically be in it's own file, and contain one or more complete functions and /or object definitions.
A "snippet" could be any small piece of code, perhaps only part of a function.
![Routine Poutine](https://uploads.teamtreehouse.com/production/profile-photos/9710132/micro_514px-Food_at_WIkimanian_2017_02.jpg)
Routine Poutine
26,050 PointsSteven, That’s very helpful, thanks!
![JASON LEE](https://secure.gravatar.com/avatar/798eb96d4c2cc69af1ecaf0ccb0b8be5?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
JASON LEE
17,352 PointsSo then wouldn't a "library" be the same as a "module"? Or is a library essentially just a really big module?
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsSure, a module could be described as a "library".