Updated the code:
async function RequestStreams() {
got({
url: "https://api.twitch.tv/helix/streams/metadata",
method: "GET",
headers: {
'Client-ID': TwitchClientID
},
responseType: "json"
}).then(resp => {
console.log("Ok", resp.body);
if (resp.body.expires_in <= 3600) {
twitch.makeClientCred();
} else {
// it"s ok
}
}).catch(err => {
console.log('Error Time!')
console.error(err);
});
}
And the Error I get is
Error Time!
HTTPError: Response code 404 (Not Found)
at onResponse (D:\Twitch API Development\TwitchAppAnalytics\node_modules\got\dist\source\as-promise\index.js:124:28)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: undefined,
timings: {
start: 1592764794808,
socket: 1592764794808,
lookup: 1592764794808,
connect: 1592764794817,
secureConnect: 1592764794839,
upload: 1592764794840,
response: 1592764794989,
end: 1592764794990,
error: undefined,
abort: undefined,
phases: {
wait: 0,
dns: 0,
tcp: 9,
tls: 22,
request: 1,
firstByte: 149,
download: 1,
total: 182
}
}
}