mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
fix: update PR based on feedback
This commit is contained in:
parent
c10525108e
commit
4d0d39891a
@ -4,8 +4,9 @@ import { formatApiPath } from '../../../../utils/format-path';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
|
||||
const useApplication = (name: string, options: SWRConfiguration = {}) => {
|
||||
const path = formatApiPath(`api/admin/metrics/applications/${name}`);
|
||||
|
||||
const fetcher = async () => {
|
||||
const path = formatApiPath(`api/admin/metrics/applications/${name}`);
|
||||
return fetch(path, {
|
||||
method: 'GET',
|
||||
})
|
||||
@ -13,16 +14,16 @@ const useApplication = (name: string, options: SWRConfiguration = {}) => {
|
||||
.then(res => res.json());
|
||||
};
|
||||
|
||||
const FEATURE_CACHE_KEY = `api/admin/metrics/applications/${name}`;
|
||||
const APPLICATION_CACHE_KEY = `api/admin/metrics/applications/${name}`;
|
||||
|
||||
const { data, error } = useSWR(FEATURE_CACHE_KEY, fetcher, {
|
||||
const { data, error } = useSWR(APPLICATION_CACHE_KEY, fetcher, {
|
||||
...options,
|
||||
});
|
||||
|
||||
const [loading, setLoading] = useState(!error && !data);
|
||||
|
||||
const refetchApplication = () => {
|
||||
mutate(FEATURE_CACHE_KEY);
|
||||
mutate(APPLICATION_CACHE_KEY);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@ -43,7 +44,7 @@ const useApplication = (name: string, options: SWRConfiguration = {}) => {
|
||||
error,
|
||||
loading,
|
||||
refetchApplication,
|
||||
FEATURE_CACHE_KEY,
|
||||
APPLICATION_CACHE_KEY,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -3,26 +3,27 @@ import { useState, useEffect } from 'react';
|
||||
import { formatApiPath } from '../../../../utils/format-path';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
|
||||
const path = formatApiPath('api/admin/metrics/applications');
|
||||
|
||||
const useApplications = (options: SWRConfiguration = {}) => {
|
||||
const fetcher = async () => {
|
||||
const path = formatApiPath('api/admin/metrics/applications');
|
||||
return fetch(path, {
|
||||
method: 'GET',
|
||||
})
|
||||
.then(handleErrorResponses('Context data'))
|
||||
.then(handleErrorResponses('Applications data'))
|
||||
.then(res => res.json());
|
||||
};
|
||||
|
||||
const FEATURE_CACHE_KEY = 'api/admin/metrics/applications';
|
||||
const APPLICATIONS_CACHE_KEY = 'api/admin/metrics/applications';
|
||||
|
||||
const { data, error } = useSWR(FEATURE_CACHE_KEY, fetcher, {
|
||||
const { data, error } = useSWR(APPLICATIONS_CACHE_KEY, fetcher, {
|
||||
...options,
|
||||
});
|
||||
|
||||
const [loading, setLoading] = useState(!error && !data);
|
||||
|
||||
const refetchApplications = () => {
|
||||
mutate(FEATURE_CACHE_KEY);
|
||||
mutate(APPLICATIONS_CACHE_KEY);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@ -34,7 +35,7 @@ const useApplications = (options: SWRConfiguration = {}) => {
|
||||
error,
|
||||
loading,
|
||||
refetchApplications,
|
||||
FEATURE_CACHE_KEY,
|
||||
APPLICATIONS_CACHE_KEY,
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user