fix: Display network error on API fetch failure

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-11-21 00:49:14 +00:00
parent 7d0e60f5f0
commit aa80570da4

View File

@@ -10,7 +10,12 @@ function Feed({ updateCache }) {
useEffect(() => { useEffect(() => {
fetch('/api') fetch('/api')
.then(res => res.json()) .then(res => {
if (!res.ok) {
throw new Error(`Server responded with ${res.status} ${res.statusText}`);
}
return res.json();
})
.then( .then(
async (result) => { async (result) => {
const newApiStories = result.stories; const newApiStories = result.stories;