From 6dc97aaae5906c15f4799a611b39e91d3acabb15 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Sun, 27 Jul 2025 14:45:37 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=20Add=20Debug=20Logging=20to=20Thu?= =?UTF-8?q?mbnails=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added comprehensive debugging to understand the actual structure of thumbnailsResult from Neon SQL queries. This will help identify whether it's an array, object with rows, or something else entirely. --- .../api/collections/[identifier]/thumbnails.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pages/api/collections/[identifier]/thumbnails.js b/pages/api/collections/[identifier]/thumbnails.js index 9947c34..d764d81 100644 --- a/pages/api/collections/[identifier]/thumbnails.js +++ b/pages/api/collections/[identifier]/thumbnails.js @@ -114,7 +114,22 @@ export default async function handler(req, res) { LIMIT 5 `; - const thumbnails = (thumbnailsResult || []).map(card => ({ + console.log('🔍 thumbnailsResult type:', typeof thumbnailsResult); + console.log('🔍 thumbnailsResult:', thumbnailsResult); + console.log('🔍 thumbnailsResult.rows:', thumbnailsResult?.rows); + console.log('🔍 Array.isArray(thumbnailsResult):', Array.isArray(thumbnailsResult)); + + // Handle the result properly based on its structure + let thumbnailsArray; + if (Array.isArray(thumbnailsResult)) { + thumbnailsArray = thumbnailsResult; + } else if (thumbnailsResult && thumbnailsResult.rows && Array.isArray(thumbnailsResult.rows)) { + thumbnailsArray = thumbnailsResult.rows; + } else { + thumbnailsArray = []; + } + + const thumbnails = thumbnailsArray.map(card => ({ id: card.id, name: card.name, rarity: card.rarity,