Ставьте лайки-балалайки!

function loadPosts(offsetVal, append = false) { if (isLoading) return; isLoading = true; if (append) { const btn = document.getElementById('vk-load-more'); if (btn) btn.disabled = true; } else { container.innerHTML = '
⏳ Загрузка новостей...
'; } const url = 'https://api.vk.com/method/wall.get?' + new URLSearchParams({ owner_id: OWNER_ID, count: COUNT, offset: offsetVal, filter: 'all', v: V, access_token: TOKEN }); fetch(url) .then(r => r.json()) .then(response => { isLoading = false; if (response.error) { console.error('VK API error:', response.error); container.innerHTML = `
❌ Ошибка VK: ${response.error.error_msg || 'неизвестная ошибка'}
`; return; } if (response.response && response.response.items) { const newPosts = response.response.items; totalCount = response.response.count || 0; allPosts = append ? allPosts.concat(newPosts) : newPosts; allLoaded = allPosts.length >= totalCount; render(); } else { container.innerHTML = '
Не удалось получить данные
'; } }) .catch(err => { isLoading = false; console.error(err); container.innerHTML = '
❌ Ошибка сети. Проверьте соединение.
'; }); }