import { useState } from "react"; import { useAuth } from "react-oidc-context"; export function Parameters( props: { setListingData: (data: any) => void, } ) { const [error, setError] = useState('') const [isLoading, setIsLoading] = useState(false) const { user } = useAuth(); // Get user data (includes token) const fetchData = async () => { setIsLoading(true); try { const accessToken = user?.access_token; const response = await fetch('/api/listing_geojson', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}`, // Pass the token 'Content-Type': 'application/json', }, } ); if (!response.ok) throw new Error('Error: ' + response.json()); const data: Response = await response.json(); props.setListingData(data); } catch (err) { setError('Failed to fetch data: ' + err); alert(error) } finally { setIsLoading(false); } }; return <> }