Reputation: 728
My task is a very simple one, send an http/https request to a server, get back the HTML,JSON or XML and process the data.
I understand that there are 2 modules that can do the module part. nodejs.org/api/http.html and https://www.npmjs.com/package/request
I guess request is more advanced. Other than that is there any difference between the 2 which makes one more suitable or less suitable for the task I said?
Upvotes: 35
Views: 14968
Reputation: 328760
The http
package contains support for the raw HTTP protocol. While it can do everything, often it's a bit clumsy to use.
The request
module uses the http
module and adds a lot of sugar to make it easier to digest: A lot of common cases can be handled with just a tiny bit of code, it supports piping request data, forwarding requests to a different server, etc.
Upvotes: 53