{"id":24656773,"url":"https://github.com/dankreiger/puppy-fetch","last_synced_at":"2025-03-21T03:21:59.985Z","repository":{"id":42957545,"uuid":"231254382","full_name":"dankreiger/puppy-fetch","owner":"dankreiger","description":"a small wrapper for the fetch api that automatically aborts unneeded requests","archived":false,"fork":false,"pushed_at":"2023-12-15T14:52:47.000Z","size":1361,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T15:49:41.622Z","etag":null,"topics":["abortcontroller","fetch"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dankreiger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-01T19:19:58.000Z","updated_at":"2020-05-04T17:26:16.000Z","dependencies_parsed_at":"2023-02-05T03:01:27.173Z","dependency_job_id":null,"html_url":"https://github.com/dankreiger/puppy-fetch","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankreiger%2Fpuppy-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankreiger%2Fpuppy-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankreiger%2Fpuppy-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankreiger%2Fpuppy-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dankreiger","download_url":"https://codeload.github.com/dankreiger/puppy-fetch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244221104,"owners_count":20418238,"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":["abortcontroller","fetch"],"created_at":"2025-01-25T23:56:53.867Z","updated_at":"2025-03-21T03:21:59.958Z","avatar_url":"https://github.com/dankreiger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Puppy Fetch\n\nA small wrapper for the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) that uses the [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) interface to cancel in-flight fetch requests.\n\nUsing `puppy-fetch` helps by making repeated `fetch` calls abortable by default. This is especially helpful for speeding up the UX for users with a slower internet connection.\n\n[![Build Status](https://travis-ci.org/dankreiger/puppy-fetch.svg?branch=master)](https://travis-ci.org/dankreiger/puppy-fetch)\n\n[![Edit puppy-fetch](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/objective-varahamihira-hc7py?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n\n### Install\n\n```sh\nnpm install puppy-fetch\n```\n\nor\n\n```sh\nyarn add puppy-fetch\n```\n\n### Usage\n\n1. import `puppyFetch`\n\n   ```js\n   import puppyFetch from 'puppy-fetch';\n   ```\n\n2. Give `puppyFetch` a unique identifier, and then use it just like you would use the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).\n\n   ```js\n   const some_unique_string = 'some_unique_string';\n   const another_unique_string = 'another_unique_string';\n\n   // GET EXAMPLE\n   puppyFetch(\n     some_unique_string,\n     'https://jsonplaceholder.typicode.com/todos/1'\n   );\n\n   // POST EXAMPLE (note, when aborting, you should not mutate information on the server)\n   puppyFetch(another_unique_string, 'https://jsonplaceholder.typicode.com/posts', {\n     method: 'POST',\n     body: JSON.stringify({\n       title: 'foo',\n       body: 'bar',\n       userId: 1\n     }),\n     headers: {\n       'Content-type': 'application/json; charset=UTF-8'\n     }\n   });\n   ```\n\nRequests with the same unique identifier will be automatically aborted.\n\n---\n\nYou can polyfill older browsers by running:\n\n```sh\nnpm install --save abortcontroller-polyfill\n```\n\nand then importing the polyfill above your `puppy-fetch` import:\n\n```js\nimport 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';\nimport puppyFetch from 'puppy-fetch';\n```\n\nSee https://www.npmjs.com/package/abortcontroller-polyfill for more information.\n\n---\n\nMore info:\n\nAborting an instance of a finished request does nothing, and therefore is [fine to do](https://developers.google.com/web/updates/2017/09/abortable-fetch).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankreiger%2Fpuppy-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdankreiger%2Fpuppy-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankreiger%2Fpuppy-fetch/lists"}