diff --git a/server/utils/nocodb-events.ts b/server/utils/nocodb-events.ts index 7d23771..b81b468 100644 --- a/server/utils/nocodb-events.ts +++ b/server/utils/nocodb-events.ts @@ -62,18 +62,48 @@ export function createNocoDBEventsClient() { if (filters?.limit) queryParams.set('limit', filters.limit.toString()); if (filters?.offset) queryParams.set('offset', filters.offset.toString()); - // TEMPORARILY: Remove ALL filtering AND sorting to test basic functionality - // Just get all records to see if the table/API works at all - console.log('[nocodb-events] DEBUG: Testing with no filters or sorting at all'); - const url = `${baseUrl}/api/v2/tables/${eventsTableId}/records?${queryParams.toString()}`; - const response = await $fetch(url, { - method: 'GET', - headers - }); + console.log('[nocodb-events] 🔍 DEBUG: Attempting to fetch events...'); + console.log('[nocodb-events] 📋 Table ID:', eventsTableId); + console.log('[nocodb-events] 🌐 Full URL:', url); + console.log('[nocodb-events] 🔑 Token (first 10 chars):', token?.substring(0, 10) + '...'); - return response; + try { + const response = await $fetch(url, { + method: 'GET', + headers + }); + + console.log('[nocodb-events] ✅ SUCCESS! Got response'); + console.log('[nocodb-events] 📊 Response type:', typeof response); + console.log('[nocodb-events] 📝 Response keys:', Object.keys(response || {})); + + if (response && typeof response === 'object') { + const responseObj = response as any; + if (responseObj.list && Array.isArray(responseObj.list)) { + console.log('[nocodb-events] 📈 Records found:', responseObj.list.length); + if (responseObj.list.length > 0) { + console.log('[nocodb-events] 🔍 First record keys (FIELD NAMES):', Object.keys(responseObj.list[0])); + console.log('[nocodb-events] 📄 Sample record:', JSON.stringify(responseObj.list[0], null, 2)); + } + } + } + + return response; + } catch (error: any) { + console.error('[nocodb-events] ❌ FAILED with error:', error); + console.error('[nocodb-events] 🔍 Error details:', { + message: error?.message, + status: error?.status, + statusCode: error?.statusCode, + statusMessage: error?.statusMessage, + data: error?.data + }); + + // Re-throw the error so the calling code can handle it + throw error; + } }, /**