// =============================== // FETCH DELLE FOTO // =============================== async function loadPhotos() { console.log("Inizio fetch:", window.PHOTOS_URL); let res; try { res = await fetch(window.PHOTOS_URL, { headers: { "Authorization": "Bearer " + window.token } }); } catch (e) { console.error("Errore fetch:", e); return; } const text = await res.text(); if (!res.ok) { console.error(`HTTP ${res.status} ${res.statusText} – body:`, text.slice(0, 200)); return; } try { const parsed = JSON.parse(text); if (!Array.isArray(parsed)) { console.error("La risposta non è un array:", parsed); return; } window.photosData = parsed; console.log("JSON parse OK, numero foto:", parsed.length); } catch (e) { console.error("Errore nel parse JSON:", e); return; } refreshGallery(); } async function loadPhotos1() { console.log("Inizio fetch:", window.BASE_URL + "/photos"); let res; try { res = await fetch(`${window.BASE_URL}/photos`, { headers: { "Authorization": "Bearer " + window.token } }); } catch (e) { console.error("Errore fetch:", e); return; } const text = await res.text(); if (!res.ok) { console.error(`HTTP ${res.status} ${res.statusText} – body:`, text.slice(0, 200)); return; } try { const parsed = JSON.parse(text); if (!Array.isArray(parsed)) { console.error("La risposta non è un array:", parsed); return; } window.photosData = parsed; console.log("JSON parse OK, numero foto:", parsed.length); } catch (e) { console.error("Errore nel parse JSON:", e); return; } refreshGallery(); }