Registry / testing / curl2axios

curl2axios

JSON →
library0.0.3jsnpmunverified

A lightweight package (v0.0.3) that provides an Axios interceptor to generate cURL commands from Axios HTTP requests. It helps in debugging by converting Axios request configuration to equivalent cURL strings. The library ships TypeScript definitions and requires Axios ^1.6.7 as a peer dependency. Useful for developers wanting to replicate or debug Axios requests via cURL.

npm install curl2axios
INSTALL
IMPORT
SIG · CURL2AXIOS
C
curl2axios
testingjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CurlInterceptor
✓ import { CurlInterceptor } from 'curl2axios'
✗ import CurlInterceptor from 'curl2axios'
CurlInterceptor is a named export, not default. Use named import.
default
✓ import curl2axios from 'curl2axios'
✗ const { default: curl2axios } = require('curl2axios')
The module also offers a default export which is the CurlInterceptor class itself.
CurlHelper
✓ import { CurlHelper } from 'curl2axios'
✗ import { CurlHelper } from 'curl2axios' is correct; no wrong pattern.
CurlHelper is an additional named utility class.

Shows how to instantiate CurlInterceptor on an Axios instance, enable it, and make a request. The cURL for that request is logged.

import axios from 'axios'; import { CurlInterceptor } from 'curl2axios'; const axiosInstance = axios.create(); const interceptor = new CurlInterceptor(axiosInstance); interceptor.enable(); axiosInstance.get('https://api.example.com/data', { headers: { 'Authorization': 'Bearer ' + (process.env.API_KEY ?? 'test') } }).then(response => { console.log(response.data); }).catch(error => { console.error(error); }); // After the request, the generated cURL command is printed to console (via interceptor).
Debug
Known issues
gotchaInterceptor must be enabled before requests; enabling after a request does not affect past requests.
fix
Call interceptor.enable() before making any request you want to convert.
affects: >=0.0.0
deprecatedPackage is at version 0.0.3; API may change in future releases.
fix
Pin to exact version or stay updated with changelog.
affects: >=0.0.0
gotchaThe interceptor prints cURL directly to console; there is no built-in way to capture it as a variable without overriding console.log.
fix
Override console.log or fork the library to capture output.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: axios.create is not a function
Incorrect import of 'axios' (e.g., using default import where axios is not the default export).
fix
Ensure you import axios correctly: import axios from 'axios' (ESM) or const axios = require('axios') (CJS).
CurlInterceptor is not a constructor
Trying to create instance without new keyword or wrong import.
fix
Use: new CurlInterceptor(axiosInstance) or check that you imported CurlInterceptor correctly: import { CurlInterceptor } from 'curl2axios'.
Cannot read properties of undefined (reading 'enable')
Interceptor instance not created properly.
fix
Ensure interceptor is instantiated: const interceptor = new CurlInterceptor(axiosInstance);
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
axiosrequiredPeer dependency required for intercepting Axios requests.
Agent activity
11 hits · last 30 days
node
10
Resources
curl2axios — npm install curl2axios · libregistry