Spaces:
Configuration error
Configuration error
Download src/components/hooks/queries/useConfig.ts from SreejithSHR/umami: direct link, hf CLI and curl.
- Browser
- Download file 565 Bytes
-
https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/components/hooks/queries/useConfig.ts
- Command line
-
hf download hf://spaces/SreejithSHR/umami/src/components/hooks/queries/useConfig.ts
-
curl -L -o useConfig.ts https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/components/hooks/queries/useConfig.ts
565 Bytes
| import { useEffect } from 'react'; | |
| import useStore, { setConfig } from 'store/app'; | |
| import { useApi } from '../useApi'; | |
| let loading = false; | |
| export function useConfig() { | |
| const { config } = useStore(); | |
| const { get } = useApi(); | |
| const configUrl = process.env.configUrl; | |
| async function loadConfig() { | |
| const data = await get(configUrl); | |
| loading = false; | |
| setConfig(data); | |
| } | |
| useEffect(() => { | |
| if (!config && !loading && configUrl) { | |
| loading = true; | |
| loadConfig(); | |
| } | |
| }, []); | |
| return config; | |
| } | |
| export default useConfig; | |