From 46f82a6af4a5401a779a488585e144b2f0dbc5af Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 5 Jul 2024 10:18:38 -0300 Subject: [PATCH] fix: update use-get-health.ts (#2553) * update getHealth function to use options param * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../API/queries/health/use-get-health.ts | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/frontend/src/controllers/API/queries/health/use-get-health.ts b/src/frontend/src/controllers/API/queries/health/use-get-health.ts index bf9d392e4..c0250a799 100644 --- a/src/frontend/src/controllers/API/queries/health/use-get-health.ts +++ b/src/frontend/src/controllers/API/queries/health/use-get-health.ts @@ -14,39 +14,24 @@ interface getHealthResponse { export const useGetHealthQuery: useQueryFunctionType< undefined, getHealthResponse -> = (_, onFetch) => { +> = (_, options) => { const { query } = UseRequestProcessor(); - const responseFn = (data: getHealthResponse) => { - if (!onFetch) return data; - if (typeof onFetch === "function") return onFetch(data); - switch (onFetch) { - default: - return data; - } - }; - /** * Fetches the health status of the API. * * @returns {Promise>} A promise that resolves to an AxiosResponse containing the health status. */ async function getHealthFn() { - return await api.get("/health_check"); + return (await api.get("/health_check")).data; // Health is the only endpoint that doesn't require /api/v1 } - const queryResult = query( - ["useGetHealthQuery"], - async () => { - const result = await getHealthFn(); - return responseFn(result.data); - }, - { - placeholderData: keepPreviousData, - refetchInterval: 20000, - }, - ); + const queryResult = query(["useGetHealthQuery"], getHealthFn, { + placeholderData: keepPreviousData, + refetchInterval: 20000, + ...options, + }); return queryResult; };