redux-token-api-middleware
Advanced tools
Comparing version 0.8.6 to 0.8.7
@@ -259,2 +259,11 @@ 'use strict'; | ||
}, { | ||
key: 'getToken', | ||
value: async function getToken() { | ||
var token = this.retrieveToken(); | ||
if (token instanceof Promise) { | ||
return await token; | ||
} | ||
return token; | ||
} | ||
}, { | ||
key: 'defaultAddTokenToRequest', | ||
@@ -305,10 +314,11 @@ value: function defaultAddTokenToRequest(headers, endpoint, body, token) { | ||
key: 'call', | ||
value: function call() { | ||
value: async function call() { | ||
var _this2 = this; | ||
var token = await this.getToken(); | ||
if (this.shouldRequestNewToken()) { | ||
var refreshAction = this.refreshAction(this.token); | ||
var refreshAction = this.refreshAction(token); | ||
var refreshApiAction = refreshAction[CALL_TOKEN_API]; | ||
var refreshApiActionMeta = refreshApiAction.meta || {}; | ||
var refreshArgs = this.getApiFetchArgsFromActionPayload(refreshApiAction.payload, this.token, refreshApiActionMeta.authenticate); | ||
var refreshArgs = this.getApiFetchArgsFromActionPayload(refreshApiAction.payload, token, refreshApiActionMeta.authenticate); | ||
return _crossFetch2.default.apply(null, refreshArgs).then(this.checkResponseIsOk).then(responseToCompletion).then(this.storeToken).then(function (token) { | ||
@@ -320,3 +330,3 @@ _this2.curriedApiCallMethod(token); | ||
} else { | ||
return this.curriedApiCallMethod(this.token); | ||
return this.curriedApiCallMethod(token); | ||
} | ||
@@ -348,7 +358,2 @@ } | ||
} | ||
}, { | ||
key: 'token', | ||
get: function get() { | ||
return this.retrieveToken(); | ||
} | ||
}]); | ||
@@ -355,0 +360,0 @@ |
{ | ||
"name": "redux-token-api-middleware", | ||
"version": "0.8.6", | ||
"version": "0.8.7", | ||
"description": "Redux middleware for calling APIs with token-based auth", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -156,3 +156,3 @@ import startsWith from 'lodash.startswith'; | ||
catchApiRequestError: this.defaultCatchApiRequestError, | ||
checkResponseIsOk: checkResponseIsOk, | ||
checkResponseIsOk: checkResponseIsOk | ||
} | ||
@@ -233,4 +233,8 @@ } | ||
get token() { | ||
return this.retrieveToken(); | ||
async getToken() { | ||
const token = this.retrieveToken() | ||
if (token instanceof Promise) { | ||
return await token; | ||
} | ||
return token; | ||
} | ||
@@ -275,5 +279,6 @@ | ||
call() { | ||
async call() { | ||
const token = await this.getToken(); | ||
if (this.shouldRequestNewToken()) { | ||
const refreshAction = this.refreshAction(this.token); | ||
const refreshAction = this.refreshAction(token); | ||
const refreshApiAction = refreshAction[CALL_TOKEN_API]; | ||
@@ -283,3 +288,3 @@ const refreshApiActionMeta = refreshApiAction.meta || {}; | ||
refreshApiAction.payload, | ||
this.token, | ||
token, | ||
refreshApiActionMeta.authenticate | ||
@@ -298,6 +303,5 @@ ); | ||
} else { | ||
return this.curriedApiCallMethod(this.token); | ||
return this.curriedApiCallMethod(token); | ||
} | ||
} | ||
} | ||
@@ -304,0 +308,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249199
6967