fix(frontend): Handle non-JSON API responses safely in ActivityFeed
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run

This commit is contained in:
fullsizemalt 2025-12-21 00:58:36 -08:00
parent 6ae609985e
commit ec3e327d94

View file

@ -23,11 +23,25 @@ export function ActivityFeed() {
const [loading, setLoading] = useState(true)
useEffect(() => {
fetch(`${getApiUrl()}/feed/`)
.then(res => res.json())
.then(setFeed)
.catch(console.error)
.finally(() => setLoading(false))
const fetchFeed = async () => {
try {
const res = await fetch(`${getApiUrl()}/feed/`)
if (!res.ok) {
const text = await res.text()
console.error('Feed API error:', res.status, text)
setFeed([]) // Fallback to empty
return
}
const data = await res.json()
setFeed(data)
} catch (error) {
console.error('Failed to fetch feed:', error)
setFeed([])
} finally {
setLoading(false)
}
}
fetchFeed()
}, [])
if (loading) return <div>Loading activity...</div>