I am running this:
// The parameters of fetch
const options = {
method: 'GET',
Headers: {
'Authorization': "Bearer <OAuth>",
'Client-ID': "<CLIENT_ID>",
'Content-Type': 'application/json',
},
};
// Sends fetch from Twitch's API
fetch('https://api.twitch.tv/helix/streams?first=20', options)
.then(res => console.log(res)) // expecting a json response
.then(json =>
fs.writeFile('data.log', JSON.stringify(json), function (err) {
if (err) throw err;
console.log(json);
console.log('Updated data.log!');
})
)