replace axiosInstance in the usePlugins hook to replace the api calls with the getFetchClient get method

This commit is contained in:
Simone Taeggi 2023-01-05 16:21:57 +01:00
parent bc03ef2288
commit ee4fc14689

View File

@ -1,10 +1,10 @@
import { useCallback, useEffect, useReducer } from 'react';
import { useNotification } from '@strapi/helper-plugin';
import { get } from 'lodash';
import { getFetchClient } from '@strapi/admin/admin/src/utils/getFetchClient';
import init from './init';
import pluginId from '../../pluginId';
import { cleanPermissions } from '../../utils';
import axiosInstance from '../../utils/axiosInstance';
import reducer, { initialState } from './reducer';
const usePlugins = (shouldFetchData = true) => {
@ -18,10 +18,11 @@ const usePlugins = (shouldFetchData = true) => {
dispatch({
type: 'GET_DATA',
});
const { get: getClient } = getFetchClient();
const [{ permissions }, { routes }] = await Promise.all(
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
const res = await axiosInstance.get(endpoint);
const res = await getClient(endpoint);
return res.data;
})