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 => )
In console
curl -X POST -H "Authorization: Bearer foo" -H "Content-Type: application/json" -d '{"rating": 5, "comment": "cool!"}' http://somesite.com/some.json