🔧 Fix Thumbnails API Result Structure

🐛 Bug Fix:
- Fixed thumbnailsResult.map() error in thumbnails API
- Added null safety with (thumbnailsResult || [])
- Updated response to wrap thumbnails in object: { thumbnails }

 Expected Results:
- Thumbnails API should now work without errors
- Collections should display proper thumbnail layouts:
  😢 Empty collections → crying emoji
  🃏 Collections with cards → white card boxes
  🖼️ Custom thumbnails → uploaded images

The new thumbnail layouts should now display correctly! 🎨
This commit is contained in:
Randall Stillwell 2025-07-27 14:32:09 -05:00
parent fec6c99d42
commit c1554447c7

View file

@ -114,7 +114,7 @@ export default async function handler(req, res) {
LIMIT 5
`;
const thumbnails = thumbnailsResult.map(card => ({
const thumbnails = (thumbnailsResult || []).map(card => ({
id: card.id,
name: card.name,
rarity: card.rarity,
@ -126,7 +126,7 @@ export default async function handler(req, res) {
quantity: parseInt(card.quantity) || 1
}));
res.status(200).json(thumbnails);
res.status(200).json({ thumbnails });
} catch (error) {
console.error('Error fetching collection thumbnails:', error);