Registry / testing / nestjs-convert-to-curl

nestjs-convert-to-curl

JSON →
library2.0.7jsnpmunverified

A lightweight TypeScript utility to convert Axios requests and errors into cURL commands for debugging and logging. Version 2.0.7 is released under MIT license. It supports all common HTTP methods, query parameters, headers, request bodies (JSON, strings, buffers), and anonymization of sensitive fields (including nested fields via dot notation). Unlike alternatives that require manual formatting, it integrates directly with Axios config and error objects. The package is ESM-only and ships TypeScript types. Release cadence is stable, with minor updates.

npm install nestjs-convert-to-curl
INSTALL
IMPORT
SIG · NESTJS-CONVERT-TO-
N
nestjs-convert-to-curl
testingjavascriptv2.0.7
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.

AxiosConverter
import { AxiosConverter } from 'nestjs-convert-to-curl'
const { AxiosConverter } = require('nestjs-convert-to-curl')
ESM-only package; CommonJS require will fail. Use dynamic import() if needed.
AxiosConverter
const { AxiosConverter } = await import('nestjs-convert-to-curl')
const AxiosConverter = require('nestjs-convert-to-curl')
For CommonJS projects, use dynamic import with await or promise.
type CurlRequestConfig
import type { CurlRequestConfig } from 'nestjs-convert-to-curl'
import { CurlRequestConfig } from 'nestjs-convert-to-curl'
Type imports should use `import type` to avoid runtime errors if the type is not exported as a value.

Demonstrates catching an Axios error and converting it to a cURL command for debugging.

import axios from 'axios'; import { AxiosConverter } from 'nestjs-convert-to-curl'; try { await axios.post('https://api.example.com/users', { name: 'John Doe', email: 'john@example.com' }); } catch (error) { console.log(AxiosConverter.getCurl(error)); }
Debug
Known issues
breakingPackage is ESM-only; CommonJS require() does not work.
fix
Use import statements or dynamic import() in CommonJS projects.
affects: >=2.0
gotchagetCurl() expects either an Axios error object or an Axios request config object; passing other types may throw.
fix
Ensure you pass an Axios error (from catch) or an Axios config object (with method, url, etc.).
affects: all
gotchaanonymizedFields only affect JSON body; sensitive fields in headers or URL are not anonymized by default.
fix
Manually sanitize headers and URL if needed, or open a feature request.
affects: all
deprecatedThe package previously exported a default export; in v2.0+ only named export AxiosConverter is available.
fix
Change to import { AxiosConverter } from 'nestjs-convert-to-curl'.
affects: >=2.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'config' of undefined
Passing an undefined or non-Axios error object to getCurl.
fix
Ensure the argument is an Axios error (e.g., catch (error) {...}) and error.response exists.
TypeError: Cannot read properties of undefined (reading 'method')
Passing an incomplete Axios config object missing 'method' or 'url'.
fix
Provide a config object with at least 'method' and 'url' properties.
error: require() of ES Module not supported
Using CommonJS require() with an ESM-only package.
fix
Use import or use dynamic import() inside an async function.
Upgrade
Version history
2.0.7latest on npm
Audit
Dependencies
axiosrequiredThe library operates on Axios request config and Axios error objects; it is a peer dependency.
Agent activity
4 hits · last 30 days
node
4
Resources
nestjs-convert-to-curl — npm install nestjs-convert-to-curl · libregistry