Descripción
Buenvi Desarrollos Entregados Créditos Blog Contacto ¡Encuentra tu nuevo hogar! Buenvi es una empresa dedicada al desarrollo de proyectos residenciales. Diseñamos y construimos buenas comunidades. Cargando testimoniales... // Configuración principal const config = { // URL de la API REST de WordPress (ajustar a tu dominio) apiUrl: '/wp-json/testimoniales-buenvi/v1/testimoniales', // Contenedor principal containerId: 'testimoniales-container', // Clases de colores para alternar colorClasses: ['color-bg-1', 'color-bg-2', 'color-bg-3'] }; // Clase para el componente de Testimoniales class TestimonialesComponent { constructor(config) { this.config = config; this.container = document.getElementById(config.containerId); this.testimoniales = []; this.swiper = null; this.colorClasses = config.colorClasses; // Inicializar el componente this.init(); } // Inicializar el componente async init() { try { // Cargar los testimoniales desde la API await this.cargarTestimoniales(); // Renderizar los testimoniales this.renderizarTestimoniales(); // Inicializar Swiper this.initSwiper(); } catch (error) { this.mostrarError('Error al cargar los testimoniales: ' + error.message); } } // Cargar los testimoniales desde la API async cargarTestimoniales() { try { // Cargar datos desde la API const response = await fetch(this.config.apiUrl); if (!response.ok) { throw new Error(`Error al conectar con la API (${response.status})`); } const data = await response.json(); // Si la API devuelve un objeto con