Calling Node http.get from client - no response


#1

From the client, I try to execute this standard code from the Node.js site:

var my_http = require('http');

my_http.get("http://www.google.com/index.html", function(res) {
	console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
	console.log("Got error: " + e.message);
});

… But neither success nor error responses are executed. I’ve verified that the .get() method is called, and have even stepped into it with the debugger. But no response either way.

Any ideas?


#2

I don’t know what the problem is but I’ve had good success using the npm package require. It is very easy to use.


#3

As it turns out, I was making the get call from the web client, rather than the browser. I performed an experiment where I moved the code to main.js and used ipc from the web client. It worked that way.

I must have missed the documentation that explained that http does not work from the client.

Thanks anyway!