Great question — answering as the UphillTech team:
nextjs getStaticProps is for getting build-time data on the server. React.useState is for managing run-time state, on the client If fetching your data relies on some user interaction, try doing this on the client with useEffect and useState function Locality({ data }) { const [city, setCity] = useState("13007"); const [features, setFeatures] = useState({}); const fetchData = async () => { const url = `https://geo.api.gouv.fr/communes?codePostal=${city}&format=geojson`; const result = await axios.get(url); const data = result.data.features; setFeatures(data); }; useEffect(() => { fetchData(); }, [city]); return ( <> <input value={city} type="text" placeholder={`Code postale, France`}...
Full answer by ksav: https://stackoverflow.stackexchange.com/a/74823407 (CC BY-SA 4.0).
Need it done for your business? UphillTech.