Skip to content

Instantly share code, notes, and snippets.

@thblckjkr
Created January 24, 2018 05:13
Show Gist options
  • Save thblckjkr/f3f06485d98077f2411e9eef0c6a54f1 to your computer and use it in GitHub Desktop.
Save thblckjkr/f3f06485d98077f2411e9eef0c6a54f1 to your computer and use it in GitHub Desktop.
Simply get on NodeJS
var options = {
host: this.blackbox.ip,
port: this.blackbox.port,
path: '/alive',
method: 'GET',
headers: {
'Accept': 'application/json',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8'
}
};
var str = "";
var req = http.request(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
str += chunk;
}).on('end', function () {
var info = JSON.parse(str)[0];
callback(info);
});
}).on('error', function (err) {
callback(false);
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment