document.addEventListener('DOMContentLoaded', async function() { try { // Fetch NASA APOD data const response = await fetch('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&count=6'); const data = await response.json(); const galleryContainer = document.querySelector('#gallery .grid'); galleryContainer.innerHTML = ''; // Clear loading skeletons data.forEach(item => { const galleryItem = document.createElement('div'); galleryItem.className = 'gallery-item overflow-hidden rounded-xl relative group'; galleryItem.innerHTML = `
${item.title}

${item.title}

${item.explanation}

`; galleryContainer.appendChild(galleryItem); }); // Replace feather icons after content is loaded feather.replace(); } catch (error) { console.error('Error fetching NASA data:', error); const galleryContainer = document.querySelector('#gallery .grid'); galleryContainer.innerHTML = `

Failed to load cosmic images

We're having trouble connecting to the cosmic database. Please try again later.

`; feather.replace(); } });