Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-better-stacktrace

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-better-stacktrace - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [2.0.1](https://github.com/svsool/axios-better-stacktrace/compare/v2.0.0...v2.0.1) (2021-02-14)
### Bug Fixes
* Eject interceptor on calling restore ([923eb45](https://github.com/svsool/axios-better-stacktrace/commit/923eb45a47bd4b632ea063f6691f0685e21e5653))
## [2.0.0](https://github.com/svsool/axios-better-stacktrace/compare/v1.2.0...v2.0.0) (2021-02-14)

@@ -7,0 +14,0 @@

4

lib/axiosBetterStacktrace.d.ts
import { AxiosInstance } from 'axios';
declare const patchedSym: unique symbol;
declare module 'axios' {
interface AxiosInstance {
[patchedSym]?: boolean;
}
interface AxiosRequestConfig {

@@ -4,0 +8,0 @@ topmostError?: Error;

15

lib/axiosBetterStacktrace.js

@@ -16,3 +16,3 @@ "use strict";

var isAxiosError = function (error) {
return error instanceof Error && error.isAxiosError !== undefined;
return error instanceof Error && error.isAxiosError;
};

@@ -29,5 +29,4 @@ var axiosMethods = [

];
// inherits original axios handler generics https://github.com/axios/axios/blob/79979d9214601478b67a330fc144cad25c59f3c7/index.d.ts#L139-L146
var axiosBetterStacktraceHandler = function (params, topmostError) {
// extends request config with topmostError, so it could be used inside an interceptor to enhance original error
// extend request config with topmostError, so it could be used inside an interceptor to enhance original error
switch (params.method) {

@@ -74,4 +73,4 @@ case 'request': {

};
// enhance original error with a topmostError stack trace
axiosInstance.interceptors.response.use(undefined, function (error) {
// enhance original response error with a topmostError stack trace
var responseErrorInterceptorId = axiosInstance.interceptors.response.use(undefined, function (error) {
if (isAxiosError(error) && error.config && error.config.topmostError instanceof Error) {

@@ -133,9 +132,9 @@ error.originalStack = error.stack;

});
// ensure consumer of the plugin can restore original handlers
var restoreOriginalHandlers = function () {
// ensure consumer of the plugin can restore original handlers and remove custom interceptor
return function () {
axiosInstance.interceptors.response.eject(responseErrorInterceptorId);
Object.assign(axiosInstance, originalHandlers);
};
return restoreOriginalHandlers;
};
exports.default = axiosBetterStacktrace;
//# sourceMappingURL=axiosBetterStacktrace.js.map

@@ -14,3 +14,3 @@ {

"author": "Svyatoslav Sobol <svyatoslav.sobol@gmail.com>",
"version": "2.0.0",
"version": "2.0.1",
"main": "lib/axiosBetterStacktrace.js",

@@ -17,0 +17,0 @@ "types": "lib/axiosBetterStacktrace.d.ts",

@@ -58,2 +58,9 @@ # axios-better-stacktrace

});
// you can restore original agent behavior if needed
const restoreAgent = axiosBetterStacktrace(axiosAgent);
// some code here...
restoreAgent();
```

@@ -60,0 +67,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc