initial commit
This commit is contained in:
22
src/hooks/useGetConfigs.ts
Normal file
22
src/hooks/useGetConfigs.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user