Index: frontend/js/formHandler.js
===================================================================
--- frontend/js/formHandler.js	(revision 1c51912fb1f62ebf47d6d4edd6b804c584bb0cb1)
+++ frontend/js/formHandler.js	(revision cd64b0654f6b71706257c7744e179b22c9386ade)
@@ -4,7 +4,6 @@
 
     form.addEventListener('submit', function(event) {
-        event.preventDefault(); // Prevent the default form submission
+        event.preventDefault();
 
-        // Collect form data
         const formData = new FormData(form);
         const data = {};
@@ -12,5 +11,4 @@
         let errorMessage = "";
 
-        // Validate form data
         formData.forEach((value, key) => {
             data[key] = value;
@@ -36,5 +34,4 @@
         loadingOverlay.style.display = 'flex';
 
-        // Send form data to the server
         fetch('/submit', {
             method: 'POST',
@@ -44,8 +41,12 @@
             body: JSON.stringify(data)
         })
-            .then(response => response.json())
+            .then(response => {
+                if (!response.ok) {
+                    throw new Error('Network response was not ok ' + response.statusText);
+                }
+                return response.json();
+            })
             .then(data => {
                 loadingOverlay.style.display = 'none';
-
                 const dataList = document.getElementById('givenOptions');
                 dataList.innerHTML = '';
@@ -56,92 +57,87 @@
                     wrapper.appendChild(text);
                     dataList.appendChild(wrapper);
+                } else {
+                    data.forEach(item => {
+                        const optionDiv = document.createElement('div');
+                        optionDiv.classList.add('option');
+
+                        const img = document.createElement('img');
+                        img.classList.add('image');
+                        img.src = item.imgSrc || '';
+                        optionDiv.appendChild(img);
+                        const WrapperDiv = document.createElement('div');
+                        optionDiv.appendChild(WrapperDiv);
+
+                        const nameParagraph = document.createElement('p');
+                        nameParagraph.id = 'name';
+                        nameParagraph.textContent = item.hotelName || 'N/A';
+                        WrapperDiv.appendChild(nameParagraph);
+
+                        const countryParagraph = document.createElement('p');
+                        countryParagraph.id = 'country';
+                        countryParagraph.style.fontSize = '20px';
+                        countryParagraph.textContent = item.country || 'N/A';
+                        WrapperDiv.appendChild(countryParagraph);
+
+                        const dateParagraph = document.createElement('h2');
+                        dateParagraph.id = 'date';
+                        dateParagraph.textContent = item.dateRange || 'N/A';
+                        WrapperDiv.appendChild(dateParagraph);
+
+                        const peopleParagraph = document.createElement('p');
+                        peopleParagraph.id = 'numPeople';
+                        peopleParagraph.textContent = item.numPeople === 1 ? item.numPeople + " лице" : item.numPeople + " лица";
+                        WrapperDiv.appendChild(peopleParagraph);
+
+                        const priceHeading = document.createElement('h1');
+                        priceHeading.textContent = 'Цена:';
+                        WrapperDiv.appendChild(priceHeading);
+                        const priceParagraph = document.createElement('h2');
+                        priceParagraph.id = 'price';
+                        priceParagraph.textContent = (item.price || 0) + " EUR";
+                        WrapperDiv.appendChild(priceParagraph);
+
+                        const infoDiv = document.createElement('div');
+                        infoDiv.classList.add("infoDiv");
+                        const typeRoom = document.createElement('p');
+                        typeRoom.textContent = "Тип на соба: " + (item.type || 'N/A');
+                        infoDiv.appendChild(typeRoom);
+                        const plan = document.createElement('p');
+                        plan.textContent = "Услуга: " + (item.board || 'N/A');
+                        infoDiv.appendChild(plan);
+                        const amenities = document.createElement('p');
+                        amenities.textContent = item.amenities && item.amenities.length > 0 ? "Поволности: " + item.amenities : "Нема информации од агенцијата за вклучените поволности.";
+                        infoDiv.appendChild(amenities);
+                        optionDiv.appendChild(infoDiv);
+
+                        const link = document.createElement('a');
+                        link.id = 'link';
+                        link.href = item.link || '#';
+                        link.target = '_blank';
+
+                        const button = document.createElement('button');
+                        button.classList.add('btn', 'login-button');
+                        button.textContent = 'Линк до страна';
+                        const btnWrapDiv = document.createElement('div');
+                        btnWrapDiv.classList.add('btnWrapper');
+                        const favBtn = document.createElement('button');
+                        favBtn.classList.add('favBtn', 'btn');
+                        favBtn.id = 'favBtnId';
+                        favBtn.textContent = 'Додадете во омилени';
+                        favBtn.setAttribute('data-option-id', item.id);
+                        favBtn.addEventListener('click', function () {
+                            const optionId = this.getAttribute('data-option-id');
+                            saveFavoriteOption(optionId);
+                        });
+
+                        btnWrapDiv.appendChild(link);
+                        link.appendChild(button);
+                        btnWrapDiv.appendChild(favBtn);
+
+                        optionDiv.appendChild(btnWrapDiv);
+                        dataList.appendChild(optionDiv);
+                    });
+                    console.log('Finished processing data.');
                 }
-                data.forEach(item => {
-
-                    const optionDiv = document.createElement('div');
-                    optionDiv.classList.add('option');
-
-                    //image
-                    const img = document.createElement('img');
-                    img.classList.add('image');
-                    img.src = item.imgSrc;
-                    optionDiv.appendChild(img);
-                    const WrapperDiv = document.createElement('div');
-                    optionDiv.appendChild(WrapperDiv);
-                    //hotel
-                    const nameParagraph = document.createElement('p');
-                    nameParagraph.id = 'name';
-                    nameParagraph.textContent = item.hotelName;
-                    WrapperDiv.appendChild(nameParagraph);
-                    //Destination
-                    const countryParagraph = document.createElement('p');
-                    countryParagraph.id = 'country';
-                    countryParagraph.style.fontSize = '20px';
-                    countryParagraph.textContent = item.country;
-                    WrapperDiv.appendChild(countryParagraph);
-                    const dateParagraph = document.createElement('h2');
-                    dateParagraph.id = 'date';
-                    dateParagraph.textContent = item.dateRange;
-                    WrapperDiv.appendChild(dateParagraph);
-                    const peopleParaghraph = document.createElement('p');
-                    peopleParaghraph.id = 'numPeople';
-                    if(item.numPeople === 1){
-                    peopleParaghraph.textContent = item.numPeople + " лице";
-                    }
-                    else peopleParaghraph.textContent = item.numPeople + " лица";
-                    WrapperDiv.appendChild(peopleParaghraph);
-                    //price
-                    const priceHeading = document.createElement('h1');
-                    priceHeading.textContent = 'Цена:';
-                    WrapperDiv.appendChild(priceHeading);
-                    const priceParagraph = document.createElement('h2');
-                    priceParagraph.id = 'price';
-                    priceParagraph.textContent = item.price + "EUR";
-                    WrapperDiv.appendChild(priceParagraph);
-
-
-                    const infoDiv = document.createElement('div');
-                    const typeRoom = document.createElement('p');
-                    typeRoom.textContent = "Тип на соба: " + item.type;
-                    infoDiv.appendChild(typeRoom);
-                    const plan = document.createElement('p');
-                    plan.textContent = "Услуга: " + item.board;
-                    infoDiv.appendChild(plan);
-                    const amenities = document.createElement('p');
-                    if(item.amenities.length === 0){
-                        amenities.textContent = "Нема информации од агенцијата за вклучените поволности. ";
-                    }else amenities.textContent = "Поволности: " + item.amenities;
-                    infoDiv.appendChild(amenities);
-                    optionDiv.appendChild(infoDiv);
-
-
-                    //  link and button
-                    const link = document.createElement('a');
-                    link.id = 'link';
-                    link.href = item.link; // Use item.link if available
-                    link.target = '_blank'; // Open link in new tab
-
-                    const button = document.createElement('button');
-                    button.classList.add('btn', 'login-button');
-                    button.textContent = 'Линк до страна';
-                    const btnWrapDiv = document.createElement('div');
-                    btnWrapDiv.classList.add('btnWrapper');
-                    const favBtn = document.createElement('button');
-                    favBtn.classList.add('favBtn','btn');
-                    favBtn.id = 'favBtnId';
-                    favBtn.textContent = 'Додадете во омилени';
-                    favBtn.setAttribute('data-option-id', item.id);
-                    favBtn.addEventListener('click', function () {
-                        const optionId = this.getAttribute('data-option-id');
-                        saveFavoriteOption(optionId);
-                    });
-
-                    btnWrapDiv.appendChild(link);
-                    link.appendChild(button);
-                    btnWrapDiv.appendChild(favBtn);
-
-                    optionDiv.appendChild(btnWrapDiv);
-                    dataList.appendChild(optionDiv);
-                });
                 updateFavoriteButtons();
             })
