Skip to content

Instantly share code, notes, and snippets.

@teddychan
Last active August 29, 2015 14:16
Show Gist options
  • Save teddychan/e22960a32430fd8adb9b to your computer and use it in GitHub Desktop.
Save teddychan/e22960a32430fd8adb9b to your computer and use it in GitHub Desktop.
newrelic Raw nodejs http GET request
var options = {
hostname: 'api.newrelic.com',
port: 443,
path: '/v2/servers.json',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': 'API KEY'
}
};
var https = require('https');
var content = '';
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(chunk) {
//console.log('===================================');
content += chunk.toString('utf8');
});
res.on('end', function() {
console.log('===================================');
console.log(content);
//process.stdout.write(d);
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment