I am trying to integrate a system that allows my website to detect whether a livestream is available or not so I can hide or show it depending on if the video is available.
This is also being done using Wix Velo, which makes things a bit more confusing.
I tried
export async function getLiveStatus() {
const ytKey = await getSecret("youtube_API_Key")
try {
const getIsLive = await fetch('https://www.googleapis.com/youtube/v3/videos?id=VIDEOID&part=snippet&key=API_KEY')
const data = await getIsLive.json()
return data.items[0];
} catch (err) {
console.log(err)
return err
}
}
It returned Cannot read property '0' of undefined
I was expecting it to give a json output with details about the video.