diff --git a/src/components/home/CodingNews.tsx b/src/components/home/CodingNews.tsx index 4856e508..4f22471e 100644 --- a/src/components/home/CodingNews.tsx +++ b/src/components/home/CodingNews.tsx @@ -105,7 +105,13 @@ export default function CodingNews() { throw new Error('Failed to fetch news'); } const data = await response.json(); - setNews(data); + if (Array.isArray(data)) { + setNews(data as NewsItem[]); + } else if (data && Array.isArray(data.articles)) { + setNews(data.articles as NewsItem[]); + } else { + setNews(FALLBACK_NEWS); + } } catch (err) { console.error('Error fetching news:', err); // Fall back gracefully even if fetch fails diff --git a/src/components/ui/InteractiveBackground.tsx b/src/components/ui/InteractiveBackground.tsx index b1c16f35..ab97ee33 100644 --- a/src/components/ui/InteractiveBackground.tsx +++ b/src/components/ui/InteractiveBackground.tsx @@ -1,9 +1,10 @@ 'use client'; -const DEVPATH_API = - process.env.NEXT_PUBLIC_DEVPATH_API_URL ?? 'https://api.devpath.in'; import { useEffect, useRef } from 'react'; import { useUIStore } from '@/stores/ui-store'; +const DEVPATH_API = + process.env.NEXT_PUBLIC_DEVPATH_API_URL ?? 'https://api.devpath.in'; + // Code snippets that type across the screen — dev/community themed const CODE_LINES = [ // Git diff --git a/src/context/RealTimeContext.tsx b/src/context/RealTimeContext.tsx index 3504525e..6ece0c28 100644 --- a/src/context/RealTimeContext.tsx +++ b/src/context/RealTimeContext.tsx @@ -1,8 +1,9 @@ 'use client'; +import React, { createContext, useContext, useState, useEffect } from 'react'; + const AVATAR_API = process.env.NEXT_PUBLIC_AVATAR_API_URL ?? 'https://api.dicebear.com/7.x/avataaars/svg'; -import React, { createContext, useContext, useState, useEffect } from 'react'; interface Activity { id: number;