This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/middleware/tokenInjector.js

18 lines
549 B
JavaScript
Raw Normal View History

import { CALL_API, isRSAA } from 'redux-api-middleware';
export default store => next => action => {
if (!isRSAA(action)) {
return next(action);
}
const TOKEN = store.getState().user.get('token');
console.log('GOT TOKEN', TOKEN);
if (TOKEN) {
action[CALL_API].endpoint = action[CALL_API].endpoint.query('circle-token', TOKEN );
console.log('SET URL TO', action[CALL_API].endpoint.toString());
}
action[CALL_API].endpoint = action[CALL_API].endpoint.toString(); // COnvert url object to string
return next(action);
};