{"id":21731504,"url":"https://github.com/altipla-consulting/fetch-timeout","last_synced_at":"2025-08-03T00:33:32.383Z","repository":{"id":152834025,"uuid":"625306081","full_name":"altipla-consulting/fetch-timeout","owner":"altipla-consulting","description":"Implement timeout and cancellation on top of node-fetch or standard fetch.","archived":false,"fork":false,"pushed_at":"2023-11-06T14:49:08.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T20:26:26.203Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@altipla/fetch-timeout","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/altipla-consulting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-08T17:48:09.000Z","updated_at":"2023-08-16T15:23:50.000Z","dependencies_parsed_at":"2023-11-06T23:20:00.973Z","dependency_job_id":"20c11cbf-2fc2-4c41-90a7-db6a36d8d65f","html_url":"https://github.com/altipla-consulting/fetch-timeout","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altipla-consulting%2Ffetch-timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altipla-consulting%2Ffetch-timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altipla-consulting%2Ffetch-timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altipla-consulting%2Ffetch-timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altipla-consulting","download_url":"https://codeload.github.com/altipla-consulting/fetch-timeout/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244711934,"owners_count":20497417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T04:26:17.148Z","updated_at":"2025-03-20T23:42:22.396Z","avatar_url":"https://github.com/altipla-consulting.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# fetch-timeout\n\nImplement timeout and cancellation on top of node-fetch or standard fetch.\n\n\n## Install\n\n```sh\nnpm install @altipla/fetch-timeout\n```\n\n\n## Usage\n\nReplace any call to `fetch` with our helper `fetchTimeout`. Types are compatible as we only add a new option `timeout` that can be added when needed.\n\n### With no timeout (normal fetch)\n\n```ts\nimport { fetchTimeout } from '@altipla/fetch-timeout'\n\nlet reply = await fetchTimeout('https://www.example.com/', {\n  method: 'POST',\n  body: '...',\n  headers: { ... },\n})\n```\n\n### With a timeout\n\n```ts\nimport { fetchTimeout } from '@altipla/fetch-timeout'\n\nlet reply = await fetchTimeout('https://www.example.com/', {\n  method: 'POST',\n  body: '...',\n  headers: { ... },\n  timeout: 30000, // milliseconds\n})\n```\n\n### With a timeout and a cancel signal combined\n\n```ts\nimport { fetchTimeout } from '@altipla/fetch-timeout'\n\nlet ctrl = new AbortController()\n\nabortButton.addEventListener('click', () =\u003e ctrl.abort())\n\nlet reply = await fetchTimeout('https://www.example.com/', {\n  method: 'POST',\n  body: '...',\n  headers: { ... },\n  timeout: 30000,\n  signal: controller.signal,\n})\n```\n\n\n### Check if there was a timeout\n\n```ts\nimport { fetchTimeout } from '@altipla/fetch-timeout'\n\ntry {\n  let reply = await fetchTimeout('https://www.example.com/', {\n    timeout: 5000,\n  })\n} catch (err: any) {\n  if (err.name === 'AbortError') {\n    ...\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltipla-consulting%2Ffetch-timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltipla-consulting%2Ffetch-timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltipla-consulting%2Ffetch-timeout/lists"}