Files
Mav-Mobile-UI/src/hooks/useGetConfigs.ts
2025-09-12 08:21:52 +01:00

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 };
};