Amazing Aaron Amazing Aaron - 2 months ago 5x
Node.js Question

Not even returning an error? node.js request

I have a script that GETS with http.request a website.
I have placed console.log()'s everywhere, yet can't even get it to log.
Here's my code:

var dg = {
hostname: '',
path: '/studio/plugins/info?assetId=12313013',
headers: {
'Accept-Encoding': 'gzip'

var omagawsh = http.request(dg, function(rspn) {
var strn = []
var gunzip = zlib.createGunzip();
gunzip.on('error', function(e) {

gunzip.on('data', function(chunk) {
gunzip.on('end', function() {
omagawsh.on('error', function(e) {


I am using

var zlib = require('zlib')

var http = require('http')

at the top.

Any help is much appreciated, thanks


You never actually write the request which you would do with omgawsh.end(). The request will not actually be sent until this is done.

var omagawsh = http.request(dg, function(rspn) {
    /* snip */  

Since the request is not done, the response callback is not reached. Your calls to omgawsh should be outside the callback.

var omagawsh = http.request(dg, cb);
omagawsh.on("error", handleError)

See the documentation for http.request: