{"id":28558999,"url":"https://github.com/readmeio/fetch-har","last_synced_at":"2025-06-10T08:35:54.056Z","repository":{"id":39574412,"uuid":"104525383","full_name":"readmeio/fetch-har","owner":"readmeio","description":"Issues a fetch() request from a HAR file","archived":false,"fork":false,"pushed_at":"2025-05-20T17:11:17.000Z","size":6449,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-20T18:28:39.022Z","etag":null,"topics":["fetch","har"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/readmeio.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-22T22:58:51.000Z","updated_at":"2025-05-20T17:10:06.000Z","dependencies_parsed_at":"2024-01-01T20:31:00.657Z","dependency_job_id":"821e6b30-e4fa-48f9-813b-8191c81ae80d","html_url":"https://github.com/readmeio/fetch-har","commit_stats":{"total_commits":401,"total_committers":6,"mean_commits":66.83333333333333,"dds":0.4488778054862843,"last_synced_commit":"43eed78d273ab90ff4c573ba1981a753b6fa0e19"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/readmeio%2Ffetch-har","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/readmeio%2Ffetch-har/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/readmeio%2Ffetch-har/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/readmeio%2Ffetch-har/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/readmeio","download_url":"https://codeload.github.com/readmeio/fetch-har/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/readmeio%2Ffetch-har/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039495,"owners_count":22796847,"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":["fetch","har"],"created_at":"2025-06-10T08:35:51.803Z","updated_at":"2025-06-10T08:35:54.020Z","avatar_url":"https://github.com/readmeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fetch-har\n\nMake a [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) request from a HAR definition.\n\n[![CI](https://github.com/readmeio/fetch-har/workflows/CI/badge.svg)](https://github.com/readmeio/fetch-har/)\n[![](https://img.shields.io/npm/v/fetch-har)](https://npm.im/fetch-har)\n[![License](https://img.shields.io/npm/l/fetch-har.svg)](LICENSE)\n\n[![](https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png)](https://readme.io)\n\n## Features\n\n- Supports Node 18+\n- Natively works in all browsers that support [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) without having to use any polyfills.\n- [Tested](https://github.com/readmeio/fetch-har/actions) across Chrome, Safari, Firefox on Mac, Windows, and Linux.\n- Requests can be mocked with HTTP mocking libraries like [`nock`](https://npm.im/nock), [`msw`](https://npm.im/msw), or [`fetch-mock`](https://npm.im/fetch-mock).\n\n## Installation\n\n```\nnpm install --save fetch-har\n```\n\n## Usage\n\n```js\nimport fetchHAR from 'fetch-har';\n\nconst har = {\n  log: {\n    entries: [\n      {\n        request: {\n          headers: [\n            {\n              name: 'Authorization',\n              value: 'Bearer api-key',\n            },\n            {\n              name: 'Content-Type',\n              value: 'application/json',\n            },\n          ],\n          queryString: [\n            { name: 'a', value: 1 },\n            { name: 'b', value: 2 },\n          ],\n          postData: {\n            mimeType: 'application/json',\n            text: '{\"id\":8,\"category\":{\"id\":6,\"name\":\"name\"},\"name\":\"name\"}',\n          },\n          method: 'POST',\n          url: 'http://httpbin.org/post',\n        },\n      },\n    ],\n  },\n};\n\nfetchHAR(har)\n  .then(res =\u003e res.json())\n  .then(console.log);\n```\n\n### API\n\n#### Options\n\n##### userAgent\n\nA custom `User-Agent` header to apply to your request. Please note that browsers have their own handling for these headers in `fetch()` calls so it may not work everywhere; it will always be sent in Node however.\n\n```js\nawait fetchHAR(har, { userAgent: 'my-client/1.0' });\n```\n\n##### files\n\nAn optional object map you can supply to use for `multipart/form-data` file uploads in leu of relying on if the HAR you have has [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs). It supports Node file buffers and the [File](https://developer.mozilla.org/en-US/docs/Web/API/File) API.\n\n```js\nawait fetchHAR(har, {\n  files: {\n    'owlbert.png': await fs.readFile('./owlbert.png'),\n    'file.txt': document.querySelector('#some-file-input').files[0],\n  },\n});\n```\n\nIf you don't supply this option `fetch-har` will fallback to the data URL present within the supplied HAR. If no `files` option is present, and no data URL (via `param.value`) is present in the HAR, a fatal exception will be thrown.\n\n##### init\n\nThis optional argument lets you supply any option that's available to supply to the [Request constructor](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).\n\n```js\nawait fetchHAR(har, {\n  init: {\n    headers: new Headers({\n      'x-custom-header': 'buster',\n    }),\n  },\n});\n```\n\n\u003e [!CAUTION]\n\u003e If you supply `body` or `credentials` to this option they may be overridden by what your HAR requires.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freadmeio%2Ffetch-har","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freadmeio%2Ffetch-har","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freadmeio%2Ffetch-har/lists"}