marcel marcel - 2 months ago 26x
Javascript Question

NodeJS express make get request

Is there a possibility to use express as a client-module, to make http-requests to another server?

At the moment I make requests this way:

var req = http.get({host, path}, function(res) {
res.on('data', function(chunk) {

This is too bulky. Express as server-module is very comfortable to use. I guess there's a simple way to make a get-request by using express. I don't like the express api, and I didn't find anything there.


If you want simple requests, don't use the express module, but for example request :

var request = require('request');
request('', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.