1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/apps/dashboard/features/logs/api/useServerLogs.ts
2025-02-27 15:27:54 +03:00

21 lines
652 B
TypeScript

import { Api } from '@jellyfin/sdk';
import { getSystemApi } from '@jellyfin/sdk/lib/utils/api/system-api';
import { useQuery } from '@tanstack/react-query';
import { useApi } from 'hooks/useApi';
import type { AxiosRequestConfig } from 'axios';
const fetchServerLogs = async (api: Api, options?: AxiosRequestConfig) => {
const response = await getSystemApi(api!).getServerLogs(options);
return response.data;
};
export const useServerLogs = () => {
const { api } = useApi();
return useQuery({
queryKey: [ 'ServerLogs' ],
queryFn: ({ signal }) => fetchServerLogs(api!, { signal }),
enabled: !!api
});
};