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

22 lines
652 B
TypeScript
Raw Normal View History

2024-12-17 21:35:45 +03:00
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';
2024-12-20 23:52:05 +03:00
import type { AxiosRequestConfig } from 'axios';
2024-12-17 21:35:45 +03:00
const fetchServerLogs = async (api: Api, options?: AxiosRequestConfig) => {
const response = await getSystemApi(api!).getServerLogs(options);
2024-12-17 21:35:45 +03:00
return response.data;
};
2025-01-14 01:07:56 +03:00
export const useServerLogs = () => {
2024-12-17 21:35:45 +03:00
const { api } = useApi();
return useQuery({
2025-01-14 01:57:43 +03:00
queryKey: [ 'ServerLogs' ],
queryFn: ({ signal }) => fetchServerLogs(api!, { signal }),
2024-12-17 21:35:45 +03:00
enabled: !!api
});
};