Код для получения информации о количестве подписчиков на Ютубе. Код:
const { api_key, channel_id } = "./config.json"
const fetch = require('node-fetch')
const livesubs = () => {
let response = fetch(`https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${channel_id}&key=${api_key}`)
.then(response => response.json())
.then(function (response) {
updateView(response.items[0].statistics.subscriberCount);
})};
const updateView = (subscribersCount) => {
counterValue.innerHTML = subscribersCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
};
function app() {
livesubs();
window.setInterval(livesubs, 5000);
}
Ошибка: UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined