// services/api/fetchWithTimeout.js const fetchWithTimeout = (url, options, timeout = 5000) => { const controller = new AbortController(); const id = setTimeout(() => controller.abort(), timeout); return fetch(url, { ...options, signal: controller.signal }) .then((response) => { clearTimeout(id); return response; }) .catch((error) => { clearTimeout(id); throw error; }); }; export default fetchWithTimeout;