🔍 Add Debug Logging to Thumbnails API
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.
This commit is contained in:
parent
c1554447c7
commit
6dc97aaae5
1 changed files with 16 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue