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

http.get and XMLHttpRequest

I am going over Node.js basics and AJAX basics. So, http module of Node.js is kind of a wrapper function for the XMLHttpRequest operation (callback, open and send)?

2 Answers

Thank you very much, Jeff. I think my question boils down to this: Do you need to know how to use XMLHttpRequest() to access API if you can use http(s) module from Node.js? I wonder if they are compliment or alternative to do the same task. For example, does it make sense to have a http(s) module from Node.js manage API like this course does while at the same time have a XMLHttpRequest() manage other API in one web application?

Jeff Wilton
Jeff Wilton
16,646 Points

This link has a some well-explained answers to your question, but the short answer is No.

https://www.quora.com/Does-Node-js-utilize-XMLHttpRequest

Some quotes for reference: "[Node.js] specifically uses the ECMAScript standard only, which does not natively include XMLHttpRequest." "Node.js provides its own proprietary HTTP Client API... Still there is few existing JavaScript written node.js modules on npm that provides XMLHttpRequest compliant APIs" "XMLHttpRequest is a client side concept." (whereas native Node.js is server-side)