0.0.1 • Published 6 years ago

fetch-as-curl v0.0.1

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

fetch-as-curl

Making cURL command output on browser console when using Fetch API.

Fetures

  • Make a cURL command on browser console.
  • Same interface with Fetch API.

Installation

Using npm.
npm i fetch-as-curl

Example

import "fetch-as-curl";
const options = {
  method: "POST",
  body: JSON.stringify({
    rating: 5,
    comment: "cool!"
  }),
  headers: {
    Authorization: "Bearer foo",
    "Content-Type": "application/json"
  }
}
fetch("http://somesite.com/reviews", options)
  .then(res => /* Do something */)

In console

curl -X POST -H "Authorization: Bearer foo" -H "Content-Type: application/json" -d '{"rating": 5, "comment": "cool!"}' http://somesite.com/some.json