mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
replace axiosInstance in the create Roles function to replace the api call with the useFetchClient post method
This commit is contained in:
parent
5480155dfe
commit
65bbac9aed
@ -19,12 +19,12 @@ import {
|
||||
Form,
|
||||
useNotification,
|
||||
} from '@strapi/helper-plugin';
|
||||
import useFetchClient from '@strapi/admin/admin/src/hooks/useFetchClient';
|
||||
import UsersPermissions from '../../../components/UsersPermissions';
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import pluginId from '../../../pluginId';
|
||||
import { usePlugins } from '../../../hooks';
|
||||
import schema from './utils/schema';
|
||||
import axiosInstance from '../../../utils/axiosInstance';
|
||||
|
||||
const EditPage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
@ -35,6 +35,7 @@ const EditPage = () => {
|
||||
const { isLoading: isLoadingPlugins, permissions, routes } = usePlugins();
|
||||
const { trackUsage } = useTracking();
|
||||
const permissionsRef = useRef();
|
||||
const { post } = useFetchClient();
|
||||
|
||||
const handleCreateRoleSubmit = async (data) => {
|
||||
// Set loading state
|
||||
@ -43,7 +44,7 @@ const EditPage = () => {
|
||||
try {
|
||||
const permissions = permissionsRef.current.getPermissions();
|
||||
// Update role in Strapi
|
||||
await axiosInstance.post(`/${pluginId}/roles`, { ...data, ...permissions, users: [] });
|
||||
await post(`/${pluginId}/roles`, { ...data, ...permissions, users: [] });
|
||||
// Notify success
|
||||
trackUsage('didCreateRole');
|
||||
toggleNotification({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user