redux-token-api-middleware
Advanced tools
Comparing version 0.10.0 to 0.10.1-alpha
@@ -137,4 +137,4 @@ "use strict"; | ||
function createStartAction(type, payload) { | ||
return createAsyncAction(type, 'START', payload); | ||
function createStartAction(type, payload, meta) { | ||
return createAsyncAction(type, 'START', payload, meta); | ||
} | ||
@@ -146,4 +146,4 @@ | ||
function createFailureAction(type, error) { | ||
return createAsyncAction(type, 'FAILED', new TypeError(error)); | ||
function createFailureAction(type, error, meta) { | ||
return createAsyncAction(type, 'FAILED', new TypeError(error), meta); | ||
} | ||
@@ -269,3 +269,3 @@ | ||
var fn = this.configOrDefault('catchApiRequestError'); | ||
this.dispatch(createFailureAction(type, error)); | ||
this.dispatch(createFailureAction(type, error, this.meta)); | ||
return fn(type, error); | ||
@@ -310,3 +310,3 @@ } | ||
var apiFetchArgs = this.getApiFetchArgsFromActionPayload(action.payload, token); | ||
this.dispatch(createStartAction(action.type, action.payload)); | ||
this.dispatch(createStartAction(action.type, action.payload, this.meta)); | ||
return this.apiRequest(apiFetchArgs, action, this.store); | ||
@@ -328,3 +328,3 @@ } | ||
var catchApiRequestError = this.catchApiRequestError.bind(this, action.type); | ||
this.dispatch(createStartAction(action.type, action.payload)); | ||
this.dispatch(createStartAction(action.type, action.payload, this.meta)); | ||
return Promise.all(promises).then(createResponseHandlerWithMeta(meta)).then(completeApiRequest).catch(catchApiRequestError); | ||
@@ -502,3 +502,3 @@ } | ||
return _context3.abrupt("return", _crossFetch.default.apply(null, refreshArgs).then(this.checkResponseIsOk).then(responseToCompletion).then(createResponseHandlerWithMeta(refreshApiActionMeta)).then(this.curriedApiCallMethod).catch(function (error) { | ||
_this2.dispatch(createFailureAction(_this2.apiAction.type, error)); | ||
_this2.dispatch(createFailureAction(_this2.apiAction.type, error, _this2.meta)); | ||
})); | ||
@@ -505,0 +505,0 @@ |
{ | ||
"name": "redux-token-api-middleware", | ||
"version": "0.10.0", | ||
"version": "0.10.1-alpha", | ||
"description": "Redux middleware for calling APIs with token-based auth", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -62,4 +62,4 @@ import startsWith from 'lodash.startswith'; | ||
function createStartAction(type, payload) { | ||
return createAsyncAction(type, 'START', payload); | ||
function createStartAction(type, payload, meta) { | ||
return createAsyncAction(type, 'START', payload, meta); | ||
} | ||
@@ -71,4 +71,4 @@ | ||
function createFailureAction(type, error) { | ||
return createAsyncAction(type, 'FAILED', new TypeError(error)); | ||
function createFailureAction(type, error, meta) { | ||
return createAsyncAction(type, 'FAILED', new TypeError(error), meta); | ||
} | ||
@@ -195,3 +195,3 @@ | ||
const fn = this.configOrDefault('catchApiRequestError'); | ||
this.dispatch(createFailureAction(type, error)); | ||
this.dispatch(createFailureAction(type, error, this.meta)); | ||
return fn(type, error); | ||
@@ -239,3 +239,3 @@ } | ||
); | ||
this.dispatch(createStartAction(action.type, action.payload)); | ||
this.dispatch(createStartAction(action.type, action.payload, this.meta)); | ||
return this.apiRequest(apiFetchArgs, action, this.store); | ||
@@ -254,3 +254,3 @@ } | ||
const catchApiRequestError = this.catchApiRequestError.bind(this, action.type); | ||
this.dispatch(createStartAction(action.type, action.payload)); | ||
this.dispatch(createStartAction(action.type, action.payload, this.meta)); | ||
return Promise.all(promises) | ||
@@ -344,3 +344,3 @@ .then(createResponseHandlerWithMeta(meta)) | ||
.catch(error => { | ||
this.dispatch(createFailureAction(this.apiAction.type, error)); | ||
this.dispatch(createFailureAction(this.apiAction.type, error, this.meta)); | ||
}); | ||
@@ -347,0 +347,0 @@ |
39168