NodeJS express make a request to receive

Is it possible to use express as a client module to make http requests to another server?

I am currently making queries this way:

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

This is too cumbersome. Express as a server module is very convenient to use. I assume that there is an easy way to make a request for receipt using express. I do not like express api, and I did not find anything there.

+7
javascript express
source share
1 answer

If you need simple queries, do not use the express module, but, for example, request :

 var request = require('request'); request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body) // Print the google web page. } }) 
+26
source share

All Articles