// Replace 'YOUR_API_KEY' with your actual NewsAPI key const apiKey = '57e5c0f533204d4792074af4daa2e42c'; const newsUrl = `https://newsapi.org/v2/everything?q=hacking&apiKey=${apiKey}`; async function fetchCybersecurityNews() { try { const response = await fetch(newsUrl); const data = await response.json(); const newsList = document.getElementById('news-list'); newsList.innerHTML = ''; // Clear previous news items data.articles.forEach(article => { const listItem = document.createElement('li'); listItem.innerHTML = ` ${article.title}
${article.description}
`; newsList.appendChild(listItem); }); } catch (error) { console.error('Error fetching news:', error); } } // Fetch news on page load fetchCybersecurityNews();