Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build a Simple Dynamic Site with Node.js Creating a Simple Server in Node.js Preparing & Planning

Felix Yakubov
Felix Yakubov
17,475 Points

I don't understand the flow of this course

Why do we use Node.js and not AJAX? Why do we need to create a webserver? Does it mean each website user has a webserver created for him? What does this line mean: "if url == "/" && GET"?

It feels like Node.js basic course has left me with lots of holes, and the documentation is just plain "how" and not "why"

2 Answers

Hi Felix, i'm no Node expert, i just started this week but if this is new to you then I suggest you google server-side and backend unless you have already worked with PHP or similar.

Node offer the same if not more functionality as PHP or Ruby would. Just like in PHP you would need to download and install Apache (for example) to run and test your server side code. We can do all that with NODE. But instead of downloading a web server(Apache) as we would with PHP, we build our own web server to test our code.

and

if url == "/" && GET

basically means if our url(localhost:example) is equal to page of our url (localhost:example/examplePage) AND is a GET request ... then it should do something.

Let me know if it is still a bit fuzzy.

Felix Yakubov
Felix Yakubov
17,475 Points

Thanks for the answer, its getting more clear now.

No, I haven't worked with Ruby or PHP aside the basics I needed for Wordpress customization. What bugs me is that I don't understand what I'm doing with Node.js. I mean ok, I see the commands but I can't find the logic behind it =)

Surfed some websites for more detailed node tutorial. Stumbled upon http://nodeschool.io/

Neil Bircumshaw
seal-mask
.a{fill-rule:evenodd;}techdegree
Neil Bircumshaw
Full Stack JavaScript Techdegree Student 14,597 Points

Hi Felix,

I was literally scratching my head over the same thing. The piece of coursework that is done in the last part of the JavaScript full stack tech degree dealt with AJAX and API's. Why then would you use this node server side stuff as opposed to using AJAX. AJAX just seems a lot simpler and cleaner, did you find any clarification for your answer?

Felix Yakubov
Felix Yakubov
17,475 Points

Hi Neil, Still using AJAX.. Untill I finish learning NodeJS (and then maybe understand why to use it) I will continue with AJAX. Its also simpler to save and receive data with AJAX