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

16 lines
445 B
JavaScript
Raw Permalink 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');
if (TOKEN) {
action[CALL_API].endpoint = action[CALL_API].endpoint.query('circle-token', TOKEN );
}
action[CALL_API].endpoint = action[CALL_API].endpoint.toString(); // COnvert url object to string
return next(action);
};