Add implementation using useFetchClient hook

This commit is contained in:
Christian Capeans 2022-12-12 17:34:34 +01:00
parent 745495a8d6
commit 96edc9816b

View File

@ -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);