# convert-fetch-to-curl

> Example to convert fetch to curl

Latest version **0.0.4** (published 2023-09-05) · 0 weekly downloads

## Install

```sh
npm install convert-fetch-to-curl
pnpm add convert-fetch-to-curl
yarn add convert-fetch-to-curl
bun add convert-fetch-to-curl
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-09-05 |
| First published | 2023-08-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yogesh DV |
| Maintainers | dv_yogesh |
| Keywords | log curl, fetch to curl, curl, fetch, http, request-http, debug, react-native, form curl, create curl with fetch data, create curl with axios data |

## Links

- npm: https://www.npmjs.com/package/convert-fetch-to-curl
- npm.io page: https://npm.io/package/convert-fetch-to-curl

## Dependencies (4)

- [parse-url-query-params](https://npm.io/package/parse-url-query-params.md) ^0.0.8
- [handle-window-undefined](https://npm.io/package/handle-window-undefined.md) ^0.0.6
- [disable-snapshot-testing](https://npm.io/package/disable-snapshot-testing.md) ^0.0.7
- [react-window-dimensions-hook](https://npm.io/package/react-window-dimensions-hook.md) ^0.0.7

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2023-09-05
- 0.0.3 — 2023-09-05
- 0.0.2 — 2023-08-29

## README

[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
![Tests & Build](https://github.com/leoek/convert-fetch-to-curl/workflows/Test%20&%20Build/badge.svg)
[![codecov](https://codecov.io/gh/leoek/convert-fetch-to-curl/branch/master/graph/badge.svg?token=K9L7Q3K1CL)](https://codecov.io/gh/leoek/convert-fetch-to-curl)
![Dependencies](https://img.shields.io/badge/Dependencies-%200%20-44be16)
<!-- ![Dependencies - David](https://david-dm.org/leoek/convert-fetch-to-curl.svg)-->


# Convert fetch request to curl
 This package is verymuch helpfull to developers to find curl and disscuss when ever backend apis fails, we can check all params in single shot.
 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.

Also 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:

## Installation

```sh
yarn add convert-fetch-to-curl
```

or

```sh
npm install convert-fetch-to-curl
```

## Usage

```js
import { convertFetchToCurl } from 'convert-fetch-to-curl';
// or 
//In case you donot Es Modules 
const { convertFetchToCurl } = require("convert-fetch-to-curl");

// exmple data to fetch as convert 

const url = 'https://EXMPLE_URL/posts/1';
const options = {
  headers: {
    Authorization: "BASIC SOMEBASE64STRING"
  },
  method: 'get'
};
// Log before fetch ===> convertFetchToCurl
console.log(convertFetchToCurl(url, options));
// Do your request
fetch(url, options);

// Output
curl "https://EXMPLE_URL/posts/1" -X GET -H "Authorization: BASIC SOMEBASE64STRING"

// You can also pass a single Request object 
console.log(convertFetchToCurl({
  url: "https://EXMPLE_URL/posts/1"
  headers: {
    Authorization: "BASIC SOMEBASE64STRING"
  },
  method: 'get'
}));

// and/or a Headers object as you would to with fetch
console.log(convertFetchToCurl({
  url: "https://EXMPLE_URL/posts/1"
  headers: new Headers({
    Authorization: "BASIC SOMEBASE64STRING"
  }),
  method: 'get'
}))

```

---
_Source: https://npm.io/package/convert-fetch-to-curl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
