https://github.com/chaedie/axios-curl-parser
A lightweight tool for converting Axios request configurations into cURL commands, making it easy for developers to debug or share HTTP requests.
https://github.com/chaedie/axios-curl-parser
axios curl parser
Last synced: about 1 month ago
JSON representation
A lightweight tool for converting Axios request configurations into cURL commands, making it easy for developers to debug or share HTTP requests.
- Host: GitHub
- URL: https://github.com/chaedie/axios-curl-parser
- Owner: Chaedie
- Created: 2024-11-18T20:07:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-12-24T01:56:12.000Z (10 months ago)
- Last Synced: 2025-09-12T13:24:07.014Z (about 1 month ago)
- Topics: axios, curl, parser
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/axios-curl-parser
- Size: 93.8 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Axios-curl-parser
This module is for parsing axios response to curl command format.
If your team want to make debug log with `curl` command, This module will be help you.
# Example
```ts
import axios, { AxiosResponse } from 'axios'
import { axiosResponseToCurlCommand } from 'axios-curl-parser'
axios.interceptors.response.use(async (response: AxiosResponse) => {
const curlCommand = axiosResponseToCurlCommand(response)
console.debug(curlCommand)
return response
})
axios
.get('https://jsonplaceholder.typicode.com/posts/1', {
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'Accept-Encoding': '' },
})
.then((response: any) => {})
```
## Sample Result
```shell
curl -X GET \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Accept-Encoding: " \
-H "User-Agent: axios/1.7.7" \
"https://jsonplaceholder.typicode.com/posts/1"
```
You can copy & paste for terminal and reqest curl command with this result. So you will not have to go to "network tab" on the inspector of the browser.
## Sample Usage - with Slack notification
Our team setting up the frontend error logger with `axios-curl-parser` so we just forward our error log to another developer for debugging.
curl command has all of the important information for error debugging so `axios-curl-parser` increase our team's productivity.
> Try it for your team!