SWAPI (swapi.dev) is one of the most popular APIs when learning how to fetch() data in JavaScript or React, but it only returns JSON text without any pictures.
Also, the old visual guide many tutorials relied on currently fails with SSL certificate errors.
To help anyone practicing API integration, I built a free static image CDN where every image matches the exact ID of the SWAPI resource:
const getSwapiImage = (category, swapiUrl) => { const id = swapiUrl.split('/').filter(Boolean).pop(); return https://starwarsgallery.netlify.app/assets/${category}/${id}.jpg ; };
// Example usage: const res = await fetch(' https://swapi.dev/api/people/1/' ); const luke = await res.json(); const imageUrl = getSwapiImage('people', luke.url); console.log(imageUrl); // Output: " https://starwarsgallery.netlify.app/assets/people/1.jpg "
Key features: - Same IDs as SWAPI: works across people, planets, species, starships, and vehicles (238 images).…