diff --git a/packages/core/admin/admin/src/pages/App/index.js b/packages/core/admin/admin/src/pages/App/index.js index 557f77b31f..b41a98c06f 100644 --- a/packages/core/admin/admin/src/pages/App/index.js +++ b/packages/core/admin/admin/src/pages/App/index.js @@ -25,7 +25,7 @@ import NotFoundPage from '../NotFoundPage'; import UseCasePage from '../UseCasePage'; import { getUID } from './utils'; import routes from './utils/routes'; -import { useConfigurations } from '../../hooks'; +import { useConfigurations, useFetchClient } from '../../hooks'; const AuthenticatedApp = lazy(() => import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp') @@ -37,6 +37,7 @@ function App() { const { formatMessage } = useIntl(); const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false }); const appInfo = useAppInfos(); + const { get } = useFetchClient(); const authRoutes = useMemo(() => { return makeUniqueRoutes( @@ -71,8 +72,6 @@ function App() { }, []); useEffect(() => { - const currentToken = auth.getToken(); - const getData = async () => { try { const { @@ -83,15 +82,11 @@ function App() { updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) }); - if (uuid && currentToken) { + if (uuid) { const { data: { data: properties }, - } = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`, { - headers: { - Authorization: `Bearer ${currentToken}`, - Accept: 'application/json', - 'Content-Type': 'application/json', - }, + } = await get(`/admin/telemetry-properties`, { + validateStatus: (status) => status < 500, }); setTelemetryProperties(properties);