Refactor queries to use non-null assert
This commit is contained in:
@@ -6,14 +6,9 @@ import type { AxiosRequestConfig } from 'axios';
|
||||
import { useApi } from './useApi';
|
||||
|
||||
const fetchSystemInfo = async (
|
||||
api?: Api,
|
||||
api: Api,
|
||||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
if (!api) {
|
||||
console.warn('[fetchSystemInfo] No API instance available');
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await getSystemApi(api)
|
||||
.getSystemInfo(options);
|
||||
return response.data;
|
||||
@@ -23,7 +18,7 @@ export const getSystemInfoQuery = (
|
||||
api?: Api
|
||||
) => queryOptions({
|
||||
queryKey: [ 'SystemInfo' ],
|
||||
queryFn: ({ signal }) => fetchSystemInfo(api, { signal, headers: { 'Cache-Control': 'no-cache' } }),
|
||||
queryFn: ({ signal }) => fetchSystemInfo(api!, { signal, headers: { 'Cache-Control': 'no-cache' } }),
|
||||
// Allow for query reuse in legacy javascript.
|
||||
staleTime: 1000, // 1 second
|
||||
enabled: !!api
|
||||
|
||||
Reference in New Issue
Block a user