Registry / security / axios-error-redact

axios-error-redact

JSON →
library1.1.144jsnpmunverified

Library to redact sensitive information from Axios errors. Current stable version is 1.1.144. Works with axios@^0 and axios@^1. Provides both an interceptor for axios instances and standalone usage. Key differentiator: specifically designed for Axios error redaction with configurable redaction of request/response/query data. Ships TypeScript types.

npm install axios-error-redact
INSTALL
IMPORT
SIG · AXIOS-ERROR-REDACT
A
axios-error-redact
securityjavascriptv1.1.144
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.

createErrorInterceptor
import { createErrorInterceptor } from 'axios-error-redact'
import createErrorInterceptor from 'axios-error-redact'
Named export, not default. TypeScript types included.
AxiosErrorRedactor
import { AxiosErrorRedactor } from 'axios-error-redact'
const AxiosErrorRedactor = require('axios-error-redact').AxiosErrorRedactor
Named export. The class can also be imported via destructuring.
isHttpErrorResponse
import { isHttpErrorResponse } from 'axios-error-redact'
import { isHttpErrorResponse } from 'axios-error-redact/types'
Function is exported from main entry, not a subpath. TypeScript type guard.

Shows how to use createErrorInterceptor as an axios response interceptor and the isHttpErrorResponse type guard.

import axios from 'axios'; import { createErrorInterceptor, isHttpErrorResponse } from 'axios-error-redact'; const instance = axios.create({ baseURL: 'http://example.com' }); instance.interceptors.response.use(undefined, createErrorInterceptor()); try { await instance.get(); } catch (error) { if (isHttpErrorResponse(error)) { console.error(error.response.statusMessage, error.message); } }
Debug
Known issues
gotchacreateErrorInterceptor() returns a function that should be used as the rejection handler for axios response interceptors. Passing it as the fulfillment handler will cause unexpected behavior.
fix
Ensure usage: instance.interceptors.response.use(undefined, createErrorInterceptor())
affects: *
gotchaIf the error is not an Axios error, redactError returns the original error unchanged. The isHttpErrorResponse type guard will return false.
fix
Always check the error with isHttpErrorResponse before accessing redacted properties.
affects: *
breakingVersion 1.1.0+ changed the output type to HttpErrorResponse with a fixed shape. Previously the returned structure may have differed.
fix
Update code relying on the old shape; use the documented HttpErrorResponse fields.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'axios-error-redact'
Package not installed or used in a different module resolution context.
fix
Run 'npm install axios-error-redact'
TypeError: createErrorInterceptor is not a function
Wrong import style; likely default import instead of named import.
fix
Use import { createErrorInterceptor } from 'axios-error-redact'
Property 'isErrorRedactedResponse' does not exist on type 'Error'
TypeScript type narrowing not applied; error object not checked with isHttpErrorResponse.
fix
Use if (isHttpErrorResponse(error)) { ... } to narrow type.
Upgrade
Version history
1.1.144latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; library redacts Axios errors
Agent activity
31 hits · last 30 days
node
28
Resources
axios-error-redact — npm install axios-error-redact · libregistry