Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hemanth/curl-to-fetch
Parse curl commands and returns `fetch` API equivalent.
https://github.com/hemanth/curl-to-fetch
Last synced: 5 days ago
JSON representation
Parse curl commands and returns `fetch` API equivalent.
- Host: GitHub
- URL: https://github.com/hemanth/curl-to-fetch
- Owner: hemanth
- Created: 2016-04-24T13:01:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-19T11:34:07.000Z (almost 7 years ago)
- Last Synced: 2024-11-01T09:43:13.109Z (12 days ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 25
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# curl-to-fetch
Parse curl commands and returns `fetch` API equivalent.
## Example
Input:
```
curl --cookie 'species=sloth;type=galactic' slothy https://api.sloths.com
```Output:
```js
fetch(
'https://api.sloths.com',
{headers:{"Set-Cookie":"species=sloth;type=galactic"},
method:'GET'}
)
.then(console.log, console.error)
```P.S: Supports all the `curl` flags that [parse-curl.js](https://www.npmjs.org/parse-curl/) has.
##CLI
```sh
$ c2f "curl --cookie 'species=sloth;type=galactic' slothy https://api.sloths.com"
``````sh
fetch(
https://api.sloths.com,
{headers:{"Set-Cookie":"species=sloth;type=galactic"},
method:'GET'}
)
.then(console.log, console.error)
```#API
```js
const parse = require('curl-to-fetch');
const fetchCode = parse(`curl 'http://google.com/'`);
console.log(fetchCode);
```
## Badges
![](https://img.shields.io/badge/license-MIT-blue.svg)
![](https://img.shields.io/badge/status-stable-green.svg)---
> [h3manth.com](https://h3manth.com) ·
> GitHub [@hemanth](https://github.com/hemanth) ·
> Twitter [@gnumanth](https://twitter.com/gnumanth)