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

JavaScript Node.js Basics 2017 Building a Command Line Application Making a GET Request with https

polentz
seal-mask
.a{fill-rule:evenodd;}techdegree
polentz
Full Stack JavaScript Techdegree Student 11,755 Points

A bit confused about what side we are working at...

So, we are learning that node is a runtime environment to run JS outside of the browser, and that allows developers to create server-side application. I am a bit confused now about this application printing on console information received from the treehouse API. Is this considered a client side or server side? In other words, are we coding from the point of view of a server or a client? I understand that we are not in the browser anymore (at the moment), but is this considered server to server communication (our server to treehouse's server)? or are we still acting as clients and the treehouse API is the server?

Thanks in advance

You are writing code where all most all its doing is happening at the server. The client is only getting the response after their request. In future if you are to build an app for the end-user lets say in the context of the information being returned by the treehouse API, you will have to interact with a frontend developers interface and grab the user input so that you pass it to your code that's communicating with the server and return the response that's then grabbed by the browser passed through the different styling of the Front End Developer to look simple for the end-user. They won't even know what happened back there. So you are on the serverside

3 Answers

Steven Parker
Steven Parker
229,785 Points

Anything you develop in node.js is server-side relative to your browser. But you're right that this code performs as a client relative to the the treehouse API. So this code is effectively both, but from different perspectives.

Treehouse API (server) :point_right: (client) node.js program (server) :point_right: (client) your browser

Steven Parker
Steven Parker
229,785 Points

I forgot that this project was a command-line app. So a revised diagram:

Treehouse API (server) :point_right: (client) node.js program :arrow_right: Workspace (server) :point_right: (client) your browser

polentz
seal-mask
.a{fill-rule:evenodd;}techdegree
polentz
Full Stack JavaScript Techdegree Student 11,755 Points

Steven Parker, thanks. That's very clear now :) So, in this context we are developing a command line app, the terminal would be the client? Thanks for your response

Steven Parker
Steven Parker
229,785 Points

In a sense, mostly because you're using a web browser, but it's the workspace and not the app that's the server. I added a revised diagram to my answer.