mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
replace axiosInstance in the usePlugins hook to replace the api calls with the getFetchClient get method
This commit is contained in:
parent
bc03ef2288
commit
ee4fc14689
@ -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;
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user