mirror of
https://github.com/strapi/strapi.git
synced 2025-09-17 04:17:21 +00:00
Add implementation using useFetchClient hook
This commit is contained in:
parent
745495a8d6
commit
96edc9816b
@ -25,7 +25,7 @@ import NotFoundPage from '../NotFoundPage';
|
|||||||
import UseCasePage from '../UseCasePage';
|
import UseCasePage from '../UseCasePage';
|
||||||
import { getUID } from './utils';
|
import { getUID } from './utils';
|
||||||
import routes from './utils/routes';
|
import routes from './utils/routes';
|
||||||
import { useConfigurations } from '../../hooks';
|
import { useConfigurations, useFetchClient } from '../../hooks';
|
||||||
|
|
||||||
const AuthenticatedApp = lazy(() =>
|
const AuthenticatedApp = lazy(() =>
|
||||||
import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp')
|
import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp')
|
||||||
@ -37,6 +37,7 @@ function App() {
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
|
const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
|
||||||
const appInfo = useAppInfos();
|
const appInfo = useAppInfos();
|
||||||
|
const { get } = useFetchClient();
|
||||||
|
|
||||||
const authRoutes = useMemo(() => {
|
const authRoutes = useMemo(() => {
|
||||||
return makeUniqueRoutes(
|
return makeUniqueRoutes(
|
||||||
@ -71,8 +72,6 @@ function App() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const currentToken = auth.getToken();
|
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@ -83,15 +82,11 @@ function App() {
|
|||||||
|
|
||||||
updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) });
|
updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) });
|
||||||
|
|
||||||
if (uuid && currentToken) {
|
if (uuid) {
|
||||||
const {
|
const {
|
||||||
data: { data: properties },
|
data: { data: properties },
|
||||||
} = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`, {
|
} = await get(`/admin/telemetry-properties`, {
|
||||||
headers: {
|
validateStatus: (status) => status < 500,
|
||||||
Authorization: `Bearer ${currentToken}`,
|
|
||||||
Accept: 'application/json',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setTelemetryProperties(properties);
|
setTelemetryProperties(properties);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user