You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openhamclock/src/hooks/useDXPaths.js

35 lines
820 B

/**
* useDXPaths Hook
* Fetches DX spots with coordinates for map visualization
*/
import { useState, useEffect } from 'react';
export const useDXPaths = () => {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch('/api/dxcluster/paths');
if (response.ok) {
const paths = await response.json();
setData(paths);
}
} catch (err) {
console.error('DX paths error:', err);
} finally {
setLoading(false);
}
};
fetchData();
const interval = setInterval(fetchData, 10000); // 10 seconds
return () => clearInterval(interval);
}, []);
return { data, loading };
};
export default useDXPaths;

Powered by TurnKey Linux.