import { useEffect, useState } from "react";

export function useIpData() {
  const [ipData, setIpData] = useState<string>("");

  useEffect(() => {
    const fetchIpData = async () => {
      try {
        const response = await fetch("https://api.imnya.ng/ip");
        const data = await response.text();
        setIpData(data);
      } catch (error) {
        console.error("Failed to fetch IP data:", error);
      }
    };

    fetchIpData();
  }, []);

  return ipData;
}