24 lines
586 B
TypeScript
24 lines
586 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
export const useGetConfigs = () => {
|
|
const [configs, setConfigs] = useState(null);
|
|
const apiUrl = import.meta.env.VITE_BASEURL;
|
|
useEffect(() => {
|
|
async function getConfigs() {
|
|
try {
|
|
const response = await fetch(`${apiUrl}/api/config-ids`);
|
|
|
|
if (!response.ok) {
|
|
console.log("failed fetching");
|
|
}
|
|
const data = await response.json();
|
|
setConfigs(data);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
}
|
|
getConfigs();
|
|
}, [apiUrl]);
|
|
return { configs };
|
|
};
|