mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
24 lines
640 B
TypeScript
24 lines
640 B
TypeScript
import { formatApiPath } from 'utils/formatPath';
|
|
import useSWR from 'swr';
|
|
import type { FeatureLifecycleCountSchema } from 'openapi';
|
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
|
|
|
export const useLifecycleCount = () => {
|
|
const { data, error } = useSWR<FeatureLifecycleCountSchema>(
|
|
formatApiPath('api/admin/lifecycle/count'),
|
|
fetcher,
|
|
);
|
|
|
|
return {
|
|
lifecycleCount: data,
|
|
error,
|
|
loading: !error && !data,
|
|
};
|
|
};
|
|
|
|
const fetcher = (path: string) => {
|
|
return fetch(path)
|
|
.then(handleErrorResponses('Lifecycle count'))
|
|
.then((res) => res.json());
|
|
};
|