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

redux-token-api-middleware

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-token-api-middleware - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

34

lib/index.js

@@ -137,3 +137,3 @@ 'use strict';

this.meta = this.apiAction.meta || {};
console.log('dispatch', dispatch);
// console.log('dispatch', dispatch)
this.dispatch = dispatch;

@@ -201,9 +201,9 @@ this.config = config;

console.log(action, token);
// console.log(action, token);
var apiFetchArgs = this.getApiFetchArgsFromActionPayload(action.payload, token);
console.log('apiFetchArgs');
console.log(apiFetchArgs);
console.log(this);
// console.log('apiFetchArgs');
// console.log(apiFetchArgs);
// console.log(this);
this.dispatch(createStartAction(action.type, action.payload));
this.apiRequest(apiFetchArgs, action, this.store);
return this.apiRequest(apiFetchArgs, action, this.store);
}

@@ -225,3 +225,3 @@ }, {

this.dispatch(createStartAction(action.type, action.payload));
Promise.all(promises).then(meta.responseHandler).then(completeApiRequest).catch(catchApiRequestError);
return Promise.all(promises).then(meta.responseHandler).then(completeApiRequest).catch(catchApiRequestError);
}

@@ -257,6 +257,6 @@ }, {

if (token && authenticate) {
console.log('token & authenticate');
var _addTokenToRequest = this.addTokenToRequest(headers, endpoint, body, token);
// console.log('token & authenticate');
headers = _addTokenToRequest.headers;

@@ -278,3 +278,3 @@ endpoint = _addTokenToRequest.endpoint;

var refreshArgs = this.getApiFetchArgsFromActionPayload(refreshApiAction.payload, this.token, refreshApiActionMeta.authenticate);
_isomorphicFetch2.default.apply(null, refreshArgs).then(checkResponseIsOk).then(responseToCompletion).then(this.storeToken).then(function (token) {
return _isomorphicFetch2.default.apply(null, refreshArgs).then(checkResponseIsOk).then(responseToCompletion).then(this.storeToken).then(function (token) {
_this2.curriedApiCallMethod(token);

@@ -285,5 +285,5 @@ }).catch(function (error) {

} else {
console.log('no refresh');
console.log(this.token);
this.curriedApiCallMethod(this.token);
// console.log('no refresh');
// console.log(this.token);
return this.curriedApiCallMethod(this.token);
}

@@ -322,3 +322,3 @@ }

function actionAsPromise(action, dispatch, config) {
console.log('actionAsPromise', dispatch);
// console.log('actionAsPromise', dispatch)
var apiAction = action()[CALL_TOKEN_API];

@@ -328,2 +328,4 @@ if (apiAction) {

return tokenApiService.call();
} else {
return Promise.reject('not an API action!');
}

@@ -336,3 +338,3 @@ }

console.log('createTokenApiMiddleware');
// console.log('createTokenApiMiddleware');

@@ -349,3 +351,3 @@ return function (store) {

console.log(apiAction.type);
// console.log(apiAction.type);

@@ -352,0 +354,0 @@ var tokenApiService = new TokenApiService(apiAction, store.dispatch, config);

{
"name": "redux-token-api-middleware",
"version": "0.2.0",
"version": "0.3.0",
"description": "Redux middleware for calling APIs with token-based auth",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -105,3 +105,3 @@ import _ from 'lodash';

this.meta = this.apiAction.meta || {};
console.log('dispatch', dispatch)
// console.log('dispatch', dispatch)
this.dispatch = dispatch;

@@ -177,11 +177,11 @@ this.config = config;

apiCallFromAction(action, token=null) {
console.log(action, token);
// console.log(action, token);
const apiFetchArgs = this.getApiFetchArgsFromActionPayload(
action.payload, token
);
console.log('apiFetchArgs');
console.log(apiFetchArgs);
console.log(this);
// console.log('apiFetchArgs');
// console.log(apiFetchArgs);
// console.log(this);
this.dispatch(createStartAction(action.type, action.payload));
this.apiRequest(apiFetchArgs, action, this.store);
return this.apiRequest(apiFetchArgs, action, this.store);
}

@@ -200,3 +200,3 @@

this.dispatch(createStartAction(action.type, action.payload));
Promise.all(promises)
return Promise.all(promises)
.then(meta.responseHandler)

@@ -240,3 +240,3 @@ .then(completeApiRequest)

if (token && authenticate) {
console.log('token & authenticate');
// console.log('token & authenticate');
(

@@ -263,3 +263,3 @@ { headers, endpoint, body } = this.addTokenToRequest(

);
fetch.apply(null, refreshArgs)
return fetch.apply(null, refreshArgs)
.then(checkResponseIsOk)

@@ -275,5 +275,5 @@ .then(responseToCompletion)

} else {
console.log('no refresh');
console.log(this.token);
this.curriedApiCallMethod(this.token);
// console.log('no refresh');
// console.log(this.token);
return this.curriedApiCallMethod(this.token);
}

@@ -285,3 +285,3 @@ }

export function actionAsPromise(action, dispatch, config) {
console.log('actionAsPromise', dispatch)
// console.log('actionAsPromise', dispatch)
const apiAction = action()[CALL_TOKEN_API];

@@ -291,2 +291,4 @@ if (apiAction) {

return tokenApiService.call();
} else {
return Promise.reject('not an API action!')
}

@@ -297,3 +299,3 @@ }

console.log('createTokenApiMiddleware');
// console.log('createTokenApiMiddleware');

@@ -308,3 +310,3 @@ return store => next => action => {

console.log(apiAction.type);
// console.log(apiAction.type);

@@ -311,0 +313,0 @@ const tokenApiService = new TokenApiService(

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