contact
		Heb je vragen? Neem contact met ons op!
Wij bespreken graag jouw ideeën en uitdagingen. Samen vinden we de beste oplossing voor jouw bedrijf.
			document.addEventListener('DOMContentLoaded', function () {
console.log('test')
    // Find the form
    var form = document.querySelector('.wpcf7-form');
    // Check if the form exists
    if (form) {
        // Add an event listener to handle the form submission
        form.addEventListener('submit', function (event) {
            event.preventDefault(); // Prevent default form submission
            
            // Create a FormData object from the form
            var formData = new FormData(form);
            
            // Prepare the payload according to your API structure
            var payload = {
                email: formData.get('your-email'),
                data: {
                    name: formData.get('your-name'),
                    phone: formData.get('phone'),
                    message: formData.get('your-message')
                }
            };
            
            console.log('Sending this payload to API:', payload);
            
            // Send the data to your API
            fetch('https://api.heelvoordelig.nl/api/v1/ziggo/contacts', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(payload)
            })
            .then(response => {
                if (!response.ok) {
                    throw new Error('Network response was not ok');
                }
                return response.json();
            })
            .then(data => {
                console.log('Successfully sent to external API:', data);
                // Optional: Add success notification or behavior here
                // For example, show a success message or reset the form
                form.reset();
            })
            .catch(error => {
                console.error('Error sending to external API:', error);
                // Optional: Add error notification or behavior here
            });
        });
    }
});		
				