Spaces:
Configuration error
Configuration error
Download frontend/src/hooks/query/use-get-policy.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/query/use-get-policy.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/hooks/query/use-get-policy.ts
-
curl -L -o use-get-policy.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/query/use-get-policy.ts
662 Bytes
| import { useQuery } from "@tanstack/react-query"; | |
| import React from "react"; | |
| import InvariantService from "#/api/invariant-service"; | |
| type ResponseData = string; | |
| interface UseGetPolicyConfig { | |
| onSuccess: (data: ResponseData) => void; | |
| } | |
| export const useGetPolicy = (config?: UseGetPolicyConfig) => { | |
| const data = useQuery<ResponseData>({ | |
| queryKey: ["policy"], | |
| queryFn: InvariantService.getPolicy, | |
| }); | |
| const { isFetching, isSuccess, data: policy } = data; | |
| React.useEffect(() => { | |
| if (!isFetching && isSuccess && policy) { | |
| config?.onSuccess(policy); | |
| } | |
| }, [isFetching, isSuccess, policy, config?.onSuccess]); | |
| return data; | |
| }; | |