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) {
          throw new Error("Cannot get configs");
        }
        const data = await response.json();
        setConfigs(data);
      } catch (error) {
        console.error(error);
      }
    }
    getConfigs();
  }, [apiUrl]);
  return { configs };
};
