The follows works in my quick test on v8.9.4:
var https = require('https')
function twitchLiveCheck(){
let options = {
hostname: 'api.twitch.tv',
family: 4,
path: '/kraken/users?login=darkswordsmantv',
headers: {
'Accept': 'application/vnd.twitchtv.v5+json',
'Client-ID': ''
}
}
console.log('sending twitch request');
https.get(options, function(res){
console.log('response received');
let data = "";
res.on('data', function(chunk){
console.log('adding data');
data += chunk;
});
res.on('end', function(){
console.log('data stream ended');
try {
const parsedData = data;
console.log(parsedData);
} catch (e) {
console.error("error: " + e.message);
}
});
});
}
twitchLiveCheck()
and results in:
C:\Users\....\Desktop\test>node dark.js
sending twitch request
response received
adding data
data stream ended
{"_total":1,"users":[{"display_name":"DarkSwordsmanTV","_id":"48971983","name":"darkswordsmantv","type":"user","bio":"Bio? Like Biology? I mean I guess...","created_at":"2013-09-14T13:53:29.819638Z","updated_at":"2018-02-07T00:51:16.807901Z","logo":"https://static-cdn.jtvnw.net/jtv_user_pictures/darkswordsmantv-profile_image-a0be732acd45b0c2-300x300.png"}]}