https://github.com/cdaringe/fetch-to-curl-ts
A fork of leeok/fetch-to-curl with improved TS and stream support
https://github.com/cdaringe/fetch-to-curl-ts
Last synced: about 1 year ago
JSON representation
A fork of leeok/fetch-to-curl with improved TS and stream support
- Host: GitHub
- URL: https://github.com/cdaringe/fetch-to-curl-ts
- Owner: cdaringe
- License: mit
- Created: 2024-05-13T18:32:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-17T22:50:39.000Z (about 2 years ago)
- Last Synced: 2025-03-08T19:46:40.997Z (over 1 year ago)
- Language: TypeScript
- Size: 58.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fetch-to-curl-ts
Convert [fetch](https://mdn.io/fetch) inputs to a [cURL](https://curl.se) string.
Fork of [leoek/fetch-to-curl](https://github.com/leoek/fetch-to-curl) with
improved TypeScript support and improved payload serialization.
[](https://github.com/cdaringe/fetch-to-curl-ts/actions/workflows/main.yml)
## Installation
```sh
npm install fetch-to-curl-ts
yarn add fetch-to-curl-ts
pnpm install fetch-to-curl-ts
```
## Usage
```js
import { fetchToCurl } from 'fetch-to-curl';
const curlString = await fetchToCurl('https://jsonplaceholder.typicode.com/posts/1', {
headers: {
accept: 'application/json'
}
});
// curlString ===
// curl "https://jsonplaceholder.typicode.com/posts/1" -X GET -H 'accept: application/json'
```
See [./src/__test__/main.test.ts](./src/__test__/main.test.ts) for more examples.