File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
examples/cookbook/app/network-requests Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import ContactsList from './components/ContactsList';
5
5
import FavoritesList from './components/FavoritesList' ;
6
6
import getAllContacts from './api/getAllContacts' ;
7
7
import getAllFavorites from './api/getAllFavorites' ;
8
+ import { isAxiosError } from 'axios' ;
8
9
9
10
export default ( ) => {
10
11
const [ usersData , setUsersData ] = useState < User [ ] > ( [ ] ) ;
@@ -25,7 +26,8 @@ export default () => {
25
26
try {
26
27
await Promise . all ( [ _getAllContacts ( ) , _getAllFavorites ( ) ] ) ;
27
28
} catch ( e ) {
28
- const message = 'message' in e ? e . message : 'Something went wrong' ;
29
+ const isKnownError = e instanceof Error || isAxiosError ( e ) ;
30
+ const message = isKnownError ? e . message : 'Something went wrong' ;
29
31
setError ( message ) ;
30
32
}
31
33
} ;
You can’t perform that action at this time.
0 commit comments