top of page

fetch('https://newsapi.org/v2/top-headlines?q=Disney OR Universal OR Cruise OR Sandals&apiKey=YOUR_API_KEY')
  .then(response => response.json())
  .then(data => {
    data.articles.forEach(article => {
      const link = document.createElement('a');
      link.href = article.url;
      link.innerText = article.title;

      const image = document.createElement('img');
      image.src = article.urlToImage;
      image.alt = article.title;

      const div = document.createElement('div');
      div.appendChild(image);
      div.appendChild(link);

      document.getElementById('news-container').appendChild(div);
    });
  });
 

bottom of page