I was trying to check if a twitch streamer is live or not but when I tried it gave me a error.
here is my code:
async function isStreamerLive(username) {
const theUrl = `https://api.twitch.tv/helix/streams?user_login=${username}`
const headers = {
"Client-Id": 'ID', //hidden
"Authorization": 'TOKEN', //hidden
};
const response = await fetch(theUrl, headers);
const data = await response.json();
console.log(data)
return data?.data?.find(s => s.user_login === username.toLocaleLowerCase())
}
let username = 'kaicenat'
isStreamerLive(username)
Output:
{
error: 'Unauthorized',
status: 401,
message: 'OAuth token is missing'
}
Why is it saying OAuth token is missing? I am also providing client id and token when I tried code.