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

polentz
polentz
Full Stack JavaScript Techdegree Student 11,748 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

polentz
polentz
Full Stack JavaScript Techdegree Student 11,748 Points

thanks for your response. It is still not clear to me who is the client in this context. Thanks

3 Answers

Steven Parker
Steven Parker
203,163 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
203,163 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
polentz
Full Stack JavaScript Techdegree Student 11,748 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
203,163 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.