Skip to content

Commit ac6e873

Browse files
committed
Implement useAPIErrorHandler
1 parent accfea3 commit ac6e873

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: admin/src/hooks/use-plugin-config.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
3-
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
3+
import { useAPIErrorHandler, useFetchClient, useNotification } from '@strapi/helper-plugin';
44

55
import { ACTION_RESOLVE_CONFIG } from '../constants';
66
import { pluginId } from '../utils';
77

88
const usePluginConfig = () => {
9+
const { formatAPIError } = useAPIErrorHandler();
910
const dispatch = useDispatch();
1011
const fetchClient = useFetchClient();
1112
const toggleNotification = useNotification();
@@ -32,10 +33,10 @@ const usePluginConfig = () => {
3233

3334
toggleNotification({
3435
type: 'warning',
35-
message: { id: 'notification.error' },
36+
message: formatAPIError(err),
3637
});
3738
});
38-
}, [isLoading, config, dispatch, fetchClient, toggleNotification]);
39+
}, [isLoading, config, dispatch, fetchClient, toggleNotification, formatAPIError]);
3940

4041
return {
4142
data: config,

0 commit comments

Comments
 (0)