Francisco Guardado
Image of the day

LOADING…

Gallery API - Today's APOD Custom Module

The component (ApodDisplay.tsx):                                                                    
On mount it fires two fetches in parallel. Today's APOD and the random gallery. Today's image loads into the main panel. The gallery row shows thumbnails; clicking one swaps the main display. "Back to today" resets it. All with loading states and timeout handling.

-Drupal side (server-side rendered):                                                                 
PHP fetches from the NASA API on page load, passes the data to Twig, and renders the HTML directly.

Next.js side (headless):
The component can't call NASA directly from the browser (CORS + no key management). So it calls your own Next.js route /api/apod