Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Node.js Basics!
You have completed Node.js Basics!
Preview
In this video, we'll prepare for our project and do a high-level plan.
Chrome Extension
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
In this stage, we'll build command
line applications using Node.
0:04
These apps will have no need for
any client side or
0:08
front end code because the JavaScript
we write, won't run in the browser.
0:11
As a non-blocking runtime environment,
Node.js is well equipped for
0:15
handling tasks, like working with
APIs to get data from databases.
0:20
In our command line application, we'll
search for user information from Treehouse
0:25
profiles, and print out the requested
information to the console.
0:29
We should be able to enter a user
name when we execute a program and
0:34
return the number of points and
badges a user has.
0:38
Running the app should work like this.
0:42
The node keyword, the name of
the file we want to execute, and
0:45
the user name of the Treehouse user
whose profile we want to look up.
0:50
We should get output just like this with
total badges and points in JavaScript.
0:57
Before we write any code,
we should plan what the code needs to do.
1:03
Open the workspace or download
the project files to follow along.
1:08
We need a way to check
a student's badge count and
1:14
the total number of points in
the JavaScript topic area.
1:16
Luckily, we have an efficient way of doing
this with JavaScript, thanks to Node.js.
1:20
We know we need to use Node.js, but
1:25
we need to figure out how we'll
get the profile information.
1:27
Let's go to the Treehouse profile of
a great Treehouse student turned engineer,
1:32
Carlos Salgado.
1:36
Carlos has thousands of JavaScript
points and plenty of badges.
1:39
Let's go to another student turned master,
Jennifer Nordell.
1:44
Because Jennifer is
a master of all trades,
1:50
she's completed courses as a student and
1:53
created courses as an instructor
during her time here at Treehouse.
1:55
Her account is a teacher account, and
2:00
doesn't display her point total or
any of the badges she's earned.
2:03
A program that relied only on the browser
client, wouldn't be helpful in this
2:08
situation because both profile
pages have a different format.
2:13
Try this, go to your own profile page and
type .json at the end of the URL.
2:18
Here's mine.
2:26
You get a REST API endpoint
to your profile information.
2:30
API's allow you to interact
with other programs.
2:36
Treehouse has a public API that you
can interact with for practice.
2:39
The information is a bit
difficult to read this way, so
2:44
I'll use a Chrome
extension called JSONView.
2:48
Refresh.
2:56
And this is a bit more manageable.
3:00
We can see badge information, points.
3:02
If you have a bunch of
time on your hands and
3:06
notice that your point total is
more than the combined categories,
3:10
this is because the point total also
includes points from community forum.
3:15
I provided a link in the teacher's
notes to JSONView so
3:23
you can install it if you'd like.
3:26
Now that we know where we'll get our info,
let's think about our next steps.
3:30
We need to connect to the API,
read the data returned,
3:35
parse the data, parse the data, print or
output the data to the console.
3:38
In the next video,
we'll practice getting data from an API.
3:44
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up