Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joalisonpereira/axios2curl
An axios plugin that translates requests into cURL commands
https://github.com/joalisonpereira/axios2curl
axios curl debug debuggin http javascript log logging node shell
Last synced: 23 days ago
JSON representation
An axios plugin that translates requests into cURL commands
- Host: GitHub
- URL: https://github.com/joalisonpereira/axios2curl
- Owner: joalisonpereira
- License: mit
- Created: 2023-11-17T12:57:12.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-05-08T12:24:56.000Z (6 months ago)
- Last Synced: 2024-09-15T04:39:49.882Z (about 2 months ago)
- Topics: axios, curl, debug, debuggin, http, javascript, log, logging, node, shell
- Language: TypeScript
- Homepage:
- Size: 174 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Axios2curl
![](./docs/badge-statements.svg) ![](./docs/badge-functions.svg) ![](./docs/badge-lines.svg) ![](./docs/badge-branches.svg)
An axios plugin that translates requests into cURL commands.
## Install
```bash
npm install axios2curl@latest
```## Usage
```typescript
import { axios2Curl } from 'axios2curl';
import axios from 'axios';const api = axios.create({ baseURL: 'http://localhost:3000' });
axios2Curl(api, (curl) => console.info(curl));
```#### Log
```shell
curl -X GET "http://localhost:3000/" -H "Accept: application/json, text/plain, */*"
```## Disable the logger
By default, all requests will be logged. However, you can disable this behavior on a per-request basis by setting the header `___DISABLE_CURL___` to true. Rest assured, we will remove this header before your request is processed.
```typescript
import { axios2Curl, DISABLE_CURL } from 'axios2curl';
import axios from 'axios';axios2Curl(axios, (curl) => console.info(curl));
axios
.get(
'http://localhost:3000',
headers: {
[DISABLE_CURL]: 'true'
}
)
.then(() => {
console.log('Success');
})
.catch(() => {
console.log('Error');
});
```