'use client'; import { useState, useEffect } from 'react'; interface PodcastEpisode { id: string; title: string; description: string; audio_url: string; published_at: string; duration: string; image_url: string; } interface PodcastFeed { title: string; description: string; image_url: string; episodes: PodcastEpisode[]; } const API_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://216.158.230.94:8001/api/v1'; export default function PodcastPage() { const [feed, setFeed] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchPodcasts = async () => { try { const response = await fetch(`${API_URL}/podcast/`); if (!response.ok) { throw new Error('Failed to fetch podcasts'); } const data = await response.json(); setFeed(data); } catch (err) { setError(err instanceof Error ? err.message : 'An error occurred'); } finally { setLoading(false); } }; fetchPodcasts(); }, []); if (loading) { return (
); } if (error) { return (
Error: {error}
); } return (

Podcasts

Listen to our latest episodes and stories.

{feed?.episodes.map((episode) => (
{episode.title}

{episode.title}

{new Date(episode.published_at).toLocaleDateString()} {episode.duration}
))}
); }