mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Added endpoint for fetching server-side variables.
This commit is contained in:
parent
68d35c0fc4
commit
50e491af06
8 changed files with 62 additions and 15 deletions
24
hooks/useConfig.js
Normal file
24
hooks/useConfig.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { useEffect } from 'react';
|
||||
import useStore, { setConfig } from 'store/app';
|
||||
import useApi from 'hooks/useApi';
|
||||
|
||||
let fetched = false;
|
||||
|
||||
export default function useConfig() {
|
||||
const { config } = useStore();
|
||||
const { get } = useApi();
|
||||
|
||||
async function loadConfig() {
|
||||
const { data } = await get('/config');
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!config && !fetched) {
|
||||
fetched = true;
|
||||
loadConfig();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return config || {};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue