fetch-as-curl
v0.0.1
Published
Making a cURL command from fetch API.
Downloads
5
Maintainers
Readme
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