1.2.1 • Published 6 years ago

curl-to-fetch v1.2.1

Weekly downloads
735
License
MIT
Repository
github
Last release
6 years ago

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:

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 has.

##CLI

$ c2f "curl --cookie 'species=sloth;type=galactic' slothy https://api.sloths.com"
      fetch( 
            https://api.sloths.com, 
            {headers:{"Set-Cookie":"species=sloth;type=galactic"},
            method:'GET'}
           )
           .then(console.log, console.error)

#API

const parse = require('curl-to-fetch');

const fetchCode = parse(`curl 'http://google.com/'`);

console.log(fetchCode);

Badges

npm.io npm.io


h3manth.com  ·  GitHub @hemanth  ·  Twitter @gnumanth

1.2.1

6 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago