https://github.com/yayoc/fetch-as-curl
console.log(cURL command) from Fetch API.
https://github.com/yayoc/fetch-as-curl
console-log curl fetch npm typescript
Last synced: 11 months ago
JSON representation
console.log(cURL command) from Fetch API.
- Host: GitHub
- URL: https://github.com/yayoc/fetch-as-curl
- Owner: yayoc
- Created: 2018-01-30T12:06:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-19T04:17:29.000Z (about 7 years ago)
- Last Synced: 2025-02-09T03:19:17.095Z (12 months ago)
- Topics: console-log, curl, fetch, npm, typescript
- Language: TypeScript
- Homepage:
- Size: 95.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fetch-as-curl
Making [cURL](https://curl.haxx.se/) command output on browser console when using [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

## Fetures
* Make a cURL command on browser console.
* Same interface with Fetch API.
## Installation
Using `npm`.
`npm i fetch-as-curl`
## Example
```js
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
```sh
curl -X POST -H "Authorization: Bearer foo" -H "Content-Type: application/json" -d '{"rating": 5, "comment": "cool!"}' http://somesite.com/some.json
```