diff --git a/server.js b/server.js index 0913da8..e21ddcb 100644 --- a/server.js +++ b/server.js @@ -34,7 +34,10 @@ function getUrl (req, res) { logger.info('>> getting url'); function urlQuery (callback) { try { - http.request(options).on('response', response => { + http.request(options, (response) => { + console.log(`STATUS: ${response.statusCode}`); + console.log(`HEADERS: ${JSON.stringify(response.headers)}`); + response.setEncoding('utf8'); let data = ''; response.on('data', chunk => { data += chunk; @@ -46,6 +49,19 @@ function getUrl (req, res) { logger.error(e); }); }).end(); + + /*http.request(options).on('response', response => { + let data = ''; + response.on('data', chunk => { + data += chunk; + }); + response.on('end', () => { + callback(data); + }); + response.on('error', e => { + logger.error(e); + }); + }).end();*/ } catch (e) { logger.error(e);