serp-chat / src /components /CountryLookup.jsx
matt HOFFNER
revamp
054d282
raw
history blame
410 Bytes
"use client";
import { useEffect, useState } from "react";
export default function CountryLookup() {
const [country, setCountry] = useState("United States");
useEffect(() => {
fetch(
`https://extreme-ip-lookup.com/json/?key=${process.env.NEXT_PUBLIC_IP_API_KEY}`
)
.then((res) => res.json())
.then((data) => setCountry(data.country));
}, []);
return <div>{country}</div>;
}