diff --git a/components/CollectionSelectionModal.js b/components/CollectionSelectionModal.js index eb7380a..c5691f5 100644 --- a/components/CollectionSelectionModal.js +++ b/components/CollectionSelectionModal.js @@ -23,20 +23,19 @@ export default function CollectionSelectionModal({ const fetchCollections = async () => { setLoading(true); try { - const response = await fetch('/api/collections', { - headers: { - 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` - } - }); + const response = await fetch('/api/collections'); if (response.ok) { const data = await response.json(); - setCollections(data.collections || []); + // The API returns an array directly, not wrapped in collections property + setCollections(Array.isArray(data) ? data : data.collections || []); } else { - console.error('Failed to fetch collections'); + console.error('Failed to fetch collections:', response.status, response.statusText); + setCollections([]); } } catch (error) { console.error('Error fetching collections:', error); + setCollections([]); } finally { setLoading(false); } @@ -94,8 +93,7 @@ export default function CollectionSelectionModal({ const response = await fetch(`/api/collections/${collectionId}/cards`, { method: 'POST', headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + 'Content-Type': 'application/json' }, body: JSON.stringify({ cardId: card.id,