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.explanation}
We're having trouble connecting to the cosmic database. Please try again later.