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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user