axios-patch
Advanced tools
Comparing version 0.1.0 to 0.2.0
12
index.js
@@ -5,3 +5,3 @@ 'use strict'; | ||
const contextKey = 'axiosPatch'; | ||
const patchedSym = Symbol(contextKey + 'Patched'); | ||
const patchedSym = Symbol('patched'); | ||
@@ -11,3 +11,6 @@ function init() { | ||
globalAxios.interceptors.response.use(undefined, err => { | ||
globalAxios.interceptors.response.use(res => { | ||
delete res.config[contextKey]; | ||
return res; | ||
}, err => { | ||
let stackFromOrigin = err.config[contextKey] && err.config[contextKey].stack; | ||
@@ -23,2 +26,3 @@ if (stackFromOrigin) { | ||
} | ||
delete err.config[contextKey]; | ||
return Promise.reject(err); | ||
@@ -34,3 +38,3 @@ }); | ||
const context = globalAxios[contextKey] = { }; | ||
const context = axios[contextKey] = { }; | ||
if (typeof axios.create === 'function') { | ||
@@ -91,2 +95,4 @@ patchCreate(axios, context); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.init = init; | ||
exports.default = { init }; |
{ | ||
"name": "axios-patch", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Better usage for axios", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
# axios-patch | ||
- Apply global interceptor to axios.create() automatically. | ||
- Print error stack with called origin. | ||
- Replace stack trace with originally called info. | ||
@@ -6,0 +6,0 @@ |
3119
4
83