Skip to content

Commit ed514a3

Browse files
committed
78
1 parent 18b19c0 commit ed514a3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/components/BlogList.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const BlogList = ({ isAdmin }) => {
1919
const [numberOfPosts, setNumberOfPosts] = useState(0);
2020
const [numberOfPages, setNumberOfPages] = useState(0);
2121
const [searchText, setSearchText] = useState('');
22+
const [error, setError] = useState('');
2223

2324
const { addToast } = useToast();
2425
const limit = 5;
@@ -52,6 +53,13 @@ const BlogList = ({ isAdmin }) => {
5253
setNumberOfPosts(res.headers['x-total-count']);
5354
setPosts(res.data);
5455
setLoading(false);
56+
}).catch(e => {
57+
setLoading(false);
58+
setError('Something went wrong in database');
59+
addToast({
60+
text: 'Something went wrong',
61+
type: 'danger'
62+
})
5563
})
5664
}, [isAdmin, searchText])
5765

@@ -107,6 +115,10 @@ const BlogList = ({ isAdmin }) => {
107115
}
108116
}
109117

118+
if (error) {
119+
return <div>{error}</div>
120+
}
121+
110122
return (
111123
<div>
112124
<input

0 commit comments

Comments
 (0)