Skip to content

Parse curl commands and returns `fetch` API equivalent.

Notifications You must be signed in to change notification settings

jimmywarting/curl-to-fetch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


h3manth.com  ·  GitHub @hemanth  ·  Twitter @gnumanth

About

Parse curl commands and returns `fetch` API equivalent.

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%