Files
Mav-Mobile-UI/src/hooks/useGetConfigs.ts

24 lines
586 B
TypeScript
Raw Normal View History

2025-08-13 14:23:48 +01:00
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`);
2025-09-12 08:21:52 +01:00
2025-08-13 14:23:48 +01:00
if (!response.ok) {
console.log("failed fetching");
}
const data = await response.json();
setConfigs(data);
} catch (error) {
console.log(error);
}
}
getConfigs();
}, [apiUrl]);
return { configs };
};