Last active
August 29, 2015 14:16
-
-
Save teddychan/e22960a32430fd8adb9b to your computer and use it in GitHub Desktop.
newrelic Raw nodejs http GET request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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