const fetch = require('node-fetch'); async function debugPropertyPage() { console.log('[DEBUG] Starting property page debug...'); // Check the URL path const path = '/property/villa-los-cristianos'; const match = path.match(/\/property\/([^/]+)/); console.log('[DEBUG] Path:', path, 'Match:', match ? match[1] : 'null'); if (!match) { console.log('[ERROR] No slug found in URL'); return; } const slug = match[1]; console.log('[DEBUG] Slug extracted:', slug); // Try to fetch property data try { console.log('[DEBUG] Fetching property data from API...'); const resp = await fetch('http://localhost:8080/api/properties/' + slug + '?lang=es'); console.log('[DEBUG] Response status:', resp.status); if (!resp.ok) { console.log('[ERROR] HTTP error! status:', resp.status); return; } const result = await resp.json(); console.log('[DEBUG] API response:', JSON.stringify(result, null, 2)); if (!result.success || !result.data) { console.log('[WARN] No data in response:', result); return; } const p = result.data; console.log('[SUCCESS] Loaded property:', p.title_es, 'Price:', p.price); // Simulate updating page elements console.log('[UPDATE] Updating gallery title to:', p.title_es); console.log('[UPDATE] Updating gallery location to:', p.city + ', ' + p.zone); console.log('[UPDATE] Updating gallery price to:', Number(p.price).toLocaleString('es-ES') + ' €'); console.log('[UPDATE] Updating gallery price per m2 to:', (p.area ? Math.round(p.price / p.area) : 0) + ' €/m²'); } catch (err) { console.error('[ERROR] Failed to load property:', err); } } debugPropertyPage();