mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +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 { useCallback, useEffect, useReducer } from 'react';
|
||||||
import { useNotification } from '@strapi/helper-plugin';
|
import { useNotification } from '@strapi/helper-plugin';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
import { getFetchClient } from '@strapi/admin/admin/src/utils/getFetchClient';
|
||||||
import init from './init';
|
import init from './init';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
import { cleanPermissions } from '../../utils';
|
import { cleanPermissions } from '../../utils';
|
||||||
import axiosInstance from '../../utils/axiosInstance';
|
|
||||||
import reducer, { initialState } from './reducer';
|
import reducer, { initialState } from './reducer';
|
||||||
|
|
||||||
const usePlugins = (shouldFetchData = true) => {
|
const usePlugins = (shouldFetchData = true) => {
|
||||||
@ -18,10 +18,11 @@ const usePlugins = (shouldFetchData = true) => {
|
|||||||
dispatch({
|
dispatch({
|
||||||
type: 'GET_DATA',
|
type: 'GET_DATA',
|
||||||
});
|
});
|
||||||
|
const { get: getClient } = getFetchClient();
|
||||||
|
|
||||||
const [{ permissions }, { routes }] = await Promise.all(
|
const [{ permissions }, { routes }] = await Promise.all(
|
||||||
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
|
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
|
||||||
const res = await axiosInstance.get(endpoint);
|
const res = await getClient(endpoint);
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user