{"id":23153800,"url":"https://github.com/leoek/fetch-to-curl","last_synced_at":"2025-07-24T16:09:48.608Z","repository":{"id":38290651,"uuid":"170335650","full_name":"leoek/fetch-to-curl","owner":"leoek","description":"Convert javascript fetch requests to curl","archived":false,"fork":false,"pushed_at":"2024-12-17T15:45:44.000Z","size":1193,"stargazers_count":71,"open_issues_count":3,"forks_count":13,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T17:46:14.325Z","etag":null,"topics":["curl","fetch","javascript","javascripts-fetch","js","react","react-native"],"latest_commit_sha":null,"homepage":"","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/leoek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"leoek"}},"created_at":"2019-02-12T14:51:19.000Z","updated_at":"2025-02-10T04:59:45.000Z","dependencies_parsed_at":"2025-02-05T04:34:42.871Z","dependency_job_id":null,"html_url":"https://github.com/leoek/fetch-to-curl","commit_stats":{"total_commits":82,"total_committers":10,"mean_commits":8.2,"dds":"0.47560975609756095","last_synced_commit":"7bcdfa6496cea2a5687863f7e8479551118d676a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoek%2Ffetch-to-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoek%2Ffetch-to-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoek%2Ffetch-to-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoek%2Ffetch-to-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoek","download_url":"https://codeload.github.com/leoek/fetch-to-curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254183562,"owners_count":22028518,"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":["curl","fetch","javascript","javascripts-fetch","js","react","react-native"],"created_at":"2024-12-17T20:10:01.227Z","updated_at":"2025-05-16T18:10:36.406Z","avatar_url":"https://github.com/leoek.png","language":"JavaScript","funding_links":["https://github.com/sponsors/leoek"],"categories":[],"sub_categories":[],"readme":"[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)\n![Tests \u0026 Build](https://github.com/leoek/fetch-to-curl/workflows/Test%20\u0026%20Build/badge.svg)\n[![codecov](https://codecov.io/gh/leoek/fetch-to-curl/branch/master/graph/badge.svg?token=K9L7Q3K1CL)](https://codecov.io/gh/leoek/fetch-to-curl)\n![Dependencies](https://img.shields.io/badge/Dependencies-%200%20-44be16)\n\u003c!-- ![Dependencies - David](https://david-dm.org/leoek/fetch-to-curl.svg)--\u003e\n\n\n# fetch request to curl\n\nThis module was inspired by [http-to-curl](https://github.com/drgx/http-to-curl). Use it to generate curl requests with the inputs you would usually use for javascripts fetch. However it does not patch any modules like http-to-curl. It is just a wrapper to generate the curl string. This ensures that there are no side effects with your actual usage of fetch.\n\nAlso note that the goal of this library is to be as simple and minimal as possible. This also means that there are zero dependencies :tada:\n\n## Installation\n\n```sh\nyarn add fetch-to-curl\n```\n\nor\n\n```sh\nnpm install fetch-to-curl\n```\n\n## Usage\n\n```js\nimport { fetchToCurl } from 'fetch-to-curl';\n// or In case there is no support for Es Modules in your environment:\n// const { fetchToCurl } = require(\"fetch-to-curl\")\n\nconst url = 'https://jsonplaceholder.typicode.com/posts/1';\nconst options = {\n  headers: {\n    Authorization: \"BASIC SOMEBASE64STRING\"\n  },\n  method: 'get'\n};\n// Log yopur request\nconsole.log(fetchToCurl(url, options));\n// Do your request\nfetch(url, options);\n\n// Output\ncurl \"https://jsonplaceholder.typicode.com/posts/1\" -X GET -H \"Authorization: BASIC SOMEBASE64STRING\"\n\n// You can also pass a single Request object \nconsole.log(fetchToCurl({\n  url: \"https://jsonplaceholder.typicode.com/posts/1\"\n  headers: {\n    Authorization: \"BASIC SOMEBASE64STRING\"\n  },\n  method: 'get'\n}));\n\n// and/or a Headers object as you would to with fetch\nconsole.log(fetchToCurl({\n  url: \"https://jsonplaceholder.typicode.com/posts/1\"\n  headers: new Headers({\n    Authorization: \"BASIC SOMEBASE64STRING\"\n  }),\n  method: 'get'\n}))\n\n```\n\n## Playground and usage without package manager\n\nThere is a minimal example of usage without package manager available which allows to [directly test this in the browser console](https://leoek.github.io/fetch-to-curl/playground.html). [(view source - playground.html)](https://github.com/leoek/fetch-to-curl/blob/master/playground.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoek%2Ffetch-to-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoek%2Ffetch-to-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoek%2Ffetch-to-curl/lists"}