{"id":17472490,"url":"https://github.com/sleeplessbyte/fetch-media","last_synced_at":"2026-06-09T22:31:14.939Z","repository":{"id":42687038,"uuid":"268838545","full_name":"SleeplessByte/fetch-media","owner":"SleeplessByte","description":"Utility function that uses fetch to fetch a media-enabled resource","archived":false,"fork":false,"pushed_at":"2025-01-06T13:43:38.000Z","size":1601,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-19T22:05:06.630Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"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/SleeplessByte.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-06-02T15:28:57.000Z","updated_at":"2025-01-06T12:07:12.000Z","dependencies_parsed_at":"2023-02-14T11:16:43.558Z","dependency_job_id":null,"html_url":"https://github.com/SleeplessByte/fetch-media","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.14516129032258063","last_synced_commit":"f4959b7468eb0b70c5d72425a5ca8dec60803f92"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/SleeplessByte/fetch-media","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleeplessByte%2Ffetch-media","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleeplessByte%2Ffetch-media/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleeplessByte%2Ffetch-media/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleeplessByte%2Ffetch-media/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SleeplessByte","download_url":"https://codeload.github.com/SleeplessByte/fetch-media/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleeplessByte%2Ffetch-media/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34129072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-18T17:19:04.525Z","updated_at":"2026-06-09T22:31:14.898Z","avatar_url":"https://github.com/SleeplessByte.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fetch-media\n\nUtility function that uses fetch to fetch a media-enabled resource\n\n**Does _not_ work flawlessly with Node 18+ `fetch` because their `Response` class is implemented differently; may or may not work well with libraries that change the global `fetch`**.\n\n## Installation\n\n```bash\nyarn add fetch-media\n```\n\nIf you're using `react-native`, this will use the unbundled source _TypeScript_. As such, the normally rolled-up dependency `@ungap/url-search-params` isn't available.\n\nYou **must** install this dependency.\n\n```bash\nyarn add @ungap/url-search-params\n```\n\n## Usage\n\n```typescript\nimport { fetchMedia } from 'fetch-media';\n\n/**\n * Fetches media from a URL\n *\n * - Automatically encodes the request body if the contentType is a JSON type\n * - Automatically decodes the response body\n *    - as parsed JSON if it's JSON\n *    - as string if it's text\n *    - as ArrayBuffer or Blob if it's binary\n *    - as FormData if it's multipart/form-data\n *    - as UrlSearchParams if it has a body of url encoded form data\n * - Automatically parses errors, problems, structured errors, etc.\n *\n * @see MediaOptions\n *\n * @param url the fully qualified url to fetch from\n * @param param1 the {MediaOptions}\n * @returns A fetch promise\n */\n\nfetchMedia('https://example.org', {\n  headers: { accept: 'text/html' },\n  method: 'GET',\n}).then((result) =\u003e {\n  /* html body as string */\n});\n```\n\n---\n\nYou can use `fetchMediaWrapped` to get the full response (so you can read out headers)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleeplessbyte%2Ffetch-media","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleeplessbyte%2Ffetch-media","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleeplessbyte%2Ffetch-media/lists"}