{"id":20514150,"url":"https://github.com/webreflection/fetch","last_synced_at":"2025-06-13T15:37:53.974Z","repository":{"id":222517515,"uuid":"757506986","full_name":"WebReflection/fetch","owner":"WebReflection","description":"A fetch with Response abilities.","archived":false,"fork":false,"pushed_at":"2024-03-14T14:19:48.000Z","size":85,"stargazers_count":64,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-16T00:42:56.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/WebReflection.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":"2024-02-14T16:27:57.000Z","updated_at":"2024-03-15T09:45:08.000Z","dependencies_parsed_at":"2024-02-14T17:51:24.449Z","dependency_job_id":"8f68e856-50fd-4ebe-a32a-e7459d6bd45a","html_url":"https://github.com/WebReflection/fetch","commit_stats":null,"previous_names":["webreflection/fetch"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Ffetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Ffetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Ffetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Ffetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/fetch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232802752,"owners_count":18578684,"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-15T21:14:58.992Z","updated_at":"2025-01-06T23:50:15.523Z","avatar_url":"https://github.com/WebReflection.png","language":"JavaScript","readme":"# fetch\n\n\u003csup\u003e**Social Media Photo by [Anthony Duran](https://unsplash.com/@dogflirt) on [Unsplash](https://unsplash.com/)**\u003c/sup\u003e\n\n[![build](https://github.com/WebReflection/fetch/actions/workflows/node.js.yml/badge.svg)](https://github.com/WebReflection/fetch/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/fetch/badge.svg?branch=main)](https://coveralls.io/github/WebReflection/fetch?branch=main)\n\nA fetch with Response abilities.\n\n\u003csup\u003e(... see what I did there?)\u003c/sup\u003e\n\n```js\nimport fetch from '@webreflection/fetch';\n\n// await directly Response methods or accessors\nconsole.log(await fetch('https://google.com').text());\nconsole.log(await fetch('https://google.com').ok);\n\n// all other Promise methods just work\nconsole.log(await fetch('https://google.com').then(r =\u003e r.ok));\n```\n\nThe export is simply a Proxy that forwards to the Response any explicit intent, meaning:\n\n  * a `fetch(url, ...init)` returns exactly a `fetch(url, ...init)` reference\n    * you can do everything you could do already with `fetch` ... **this is fetch** indeed!\n    * you can use this module as drop-in replacement in your current code though\n    * you can eventually incrementally use its features *if* and/or *when* needed\n  * if any `Response.prototype` known *key* is directly accessed, such property or method is forwarded directly to the *response* once the *fetch* is resolved\n  * as the goal is to shortcut the *response* boilerplate, `Response.prototype` keys prevail over `Promise.prototype` so if your argument is that `Symbol.toStringTag` returned the response one, I am afraid that's meant by design so that unless *Promise* API introduces a conflicting entry name with *Response* API, this module actually requires zero maintainability and it's future-friendly with API changes and whatnot\n  * if you want to deal with `status` or `ok` or `headers` you still can do that:\n    * reference `const req = fetch(url, ...init)`\n    * use `try/catch` around `req.json()` or `req.text()` or any other forwarded method\n    * use `const { status, headers } = await req` or `const status = await req.status` or any other way you like to introspect the failure\n\n```js\n// alternatively ...\nconst { ok, text } = await fetch(URL);\nif (ok) console.log(await text());\n```\n\nIf none of this is interesting to you though, we're good! You can move on happily ever after 👋\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Ffetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebreflection%2Ffetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Ffetch/lists"}