Spaces:
Configuration error
Configuration error
Download utils/fetch-utils.js from carefullycraftedtree/cc_site_maker: direct link, hf CLI and curl.
- Browser
- Download file 661 Bytes
-
https://huggingface.co/spaces/carefullycraftedtree/cc_site_maker/resolve/main/utils/fetch-utils.js
- Command line
-
hf download hf://spaces/carefullycraftedtree/cc_site_maker/utils/fetch-utils.js
-
curl -L -o fetch-utils.js https://huggingface.co/spaces/carefullycraftedtree/cc_site_maker/resolve/main/utils/fetch-utils.js
661 Bytes
| /** | |
| * Fetch with timeout utility function to prevent hanging requests | |
| * @param {string} url - The URL to fetch | |
| * @param {Object} options - Fetch options | |
| * @param {number} timeout - Timeout in milliseconds | |
| * @returns {Promise<Response>} - The fetch response | |
| */ | |
| export const fetchWithTimeout = async (url, options, timeout = 10000) => { | |
| const controller = new AbortController(); | |
| const id = setTimeout(() => controller.abort(), timeout); | |
| try { | |
| const response = await fetch(url, { | |
| ...options, | |
| signal: controller.signal | |
| }); | |
| clearTimeout(id); | |
| return response; | |
| } catch (error) { | |
| clearTimeout(id); | |
| throw error; | |
| } | |
| }; | |